Skip to content

Commit dabee00

Browse files
committed
github-merge: Coalesce git fetches
Fetch the destination branch as well as PR in one go. Saves a few seconds (as well as one ssh authentication, when using a yubikey) when using github-merge.py.
1 parent 001041d commit dabee00

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

contrib/devtools/github-merge.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,10 @@ def main():
197197
print("ERROR: Cannot check out branch %s." % (branch), file=stderr)
198198
sys.exit(3)
199199
try:
200-
subprocess.check_call([GIT,'fetch','-q',host_repo,'+refs/pull/'+pull+'/*:refs/heads/pull/'+pull+'/*'])
200+
subprocess.check_call([GIT,'fetch','-q',host_repo,'+refs/pull/'+pull+'/*:refs/heads/pull/'+pull+'/*',
201+
'+refs/heads/'+branch+':refs/heads/'+base_branch])
201202
except subprocess.CalledProcessError as e:
202-
print("ERROR: Cannot find pull request #%s on %s." % (pull,host_repo), file=stderr)
203+
print("ERROR: Cannot find pull request #%s or branch %s on %s." % (pull,branch,host_repo), file=stderr)
203204
sys.exit(3)
204205
try:
205206
subprocess.check_call([GIT,'log','-q','-1','refs/heads/'+head_branch], stdout=devnull, stderr=stdout)
@@ -211,11 +212,6 @@ def main():
211212
except subprocess.CalledProcessError as e:
212213
print("ERROR: Cannot find merge of pull request #%s on %s." % (pull,host_repo), file=stderr)
213214
sys.exit(3)
214-
try:
215-
subprocess.check_call([GIT,'fetch','-q',host_repo,'+refs/heads/'+branch+':refs/heads/'+base_branch])
216-
except subprocess.CalledProcessError as e:
217-
print("ERROR: Cannot find branch %s on %s." % (branch,host_repo), file=stderr)
218-
sys.exit(3)
219215
subprocess.check_call([GIT,'checkout','-q',base_branch])
220216
subprocess.call([GIT,'branch','-q','-D',local_merge_branch], stderr=devnull)
221217
subprocess.check_call([GIT,'checkout','-q','-b',local_merge_branch])

0 commit comments

Comments
 (0)