MCPcopy Index your code
hub / github.com/git/git / createOrUpdateBranchesFromOrigin

Function createOrUpdateBranchesFromOrigin

git-p4.py:1216–1260  ·  view source on GitHub ↗
(localRefPrefix="refs/remotes/p4/", silent=True)

Source from the content-addressed store, hash-verified

1214
1215
1216def createOrUpdateBranchesFromOrigin(localRefPrefix="refs/remotes/p4/", silent=True):
1217 if not silent:
1218 print("Creating/updating branch(es) in %s based on origin branch(es)"
1219 % localRefPrefix)
1220
1221 originPrefix = "origin/p4/"
1222
1223 for line in read_pipe_lines(["git", "rev-parse", "--symbolic", "--remotes"]):
1224 line = line.strip()
1225 if (not line.startswith(originPrefix)) or line.endswith("HEAD"):
1226 continue
1227
1228 headName = line[len(originPrefix):]
1229 remoteHead = localRefPrefix + headName
1230 originHead = line
1231
1232 original = extractSettingsGitLog(extractLogMessageFromGitCommit(originHead))
1233 if 'depot-paths' not in original or 'change' not in original:
1234 continue
1235
1236 update = False
1237 if not gitBranchExists(remoteHead):
1238 if verbose:
1239 print("creating %s" % remoteHead)
1240 update = True
1241 else:
1242 settings = extractSettingsGitLog(extractLogMessageFromGitCommit(remoteHead))
1243 if 'change' in settings:
1244 if settings['depot-paths'] == original['depot-paths']:
1245 originP4Change = int(original['change'])
1246 p4Change = int(settings['change'])
1247 if originP4Change > p4Change:
1248 print("%s (%s) is newer than %s (%s). "
1249 "Updating p4 branch from origin."
1250 % (originHead, originP4Change,
1251 remoteHead, p4Change))
1252 update = True
1253 else:
1254 print("Ignoring: %s was imported from %s while "
1255 "%s was imported from %s"
1256 % (originHead, ','.join(original['depot-paths']),
1257 remoteHead, ','.join(settings['depot-paths'])))
1258
1259 if update:
1260 system(["git", "update-ref", remoteHead, originHead])
1261
1262
1263def originP4BranchesExist():

Callers 2

runMethod · 0.85
runMethod · 0.85

Calls 5

read_pipe_linesFunction · 0.85
extractSettingsGitLogFunction · 0.85
gitBranchExistsFunction · 0.85
systemFunction · 0.85

Tested by

no test coverage detected