summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChirayu Desai <cdesai@cyanogenmod.org>2013-06-16 09:47:05 +0530
committerGerrit Code Review <gerrit@cyanogenmod.org>2013-07-03 12:58:37 -0700
commitd90c6dcb029ae803e155d2a35d08e7555f12163f (patch)
treee77189bba764bfd6161a6e7d6a8529250e6f9ac6
parent98f660a629bcda4f9caccedfdba32b22b956afc4 (diff)
downloadbuild-d90c6dcb029ae803e155d2a35d08e7555f12163f.zip
build-d90c6dcb029ae803e155d2a35d08e7555f12163f.tar.gz
build-d90c6dcb029ae803e155d2a35d08e7555f12163f.tar.bz2
repopick: let's be nice to our servers :)
* Prefer fetching changes from GitHub, and if that fails, silently fall-back to Gerrit. Change-Id: Ibf68d4b69a7e8dbee2adb8f7f4250340b8be629c
-rwxr-xr-xtools/repopick.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/tools/repopick.py b/tools/repopick.py
index 6ed0d7e..ace7155 100755
--- a/tools/repopick.py
+++ b/tools/repopick.py
@@ -255,8 +255,21 @@ for change in args.change_number:
print('--> Author: %s <%s> %s' % (author_name, author_email, author_date))
print('--> Committer: %s <%s> %s' % (committer_name, committer_email, committer_date))
+ # Try fetching from GitHub first
+ if args.verbose:
+ print('Trying to fetch the change from GitHub')
+ cmd = 'cd %s && git fetch github %s' % (project_path, fetch_ref)
+ execute_cmd(cmd)
+ # Check if it worked
+ FETCH_HEAD = '%s/.git/FETCH_HEAD' % project_path
+ if os.stat(FETCH_HEAD).st_size == 0:
+ # That didn't work, fetch from Gerrit instead
+ if args.verbose:
+ print('Fetching from GitHub didn\'t work, trying to fetch the change from Gerrit')
+ cmd = 'cd %s && git fetch %s %s' % (project_path, fetch_url, fetch_ref)
+ execute_cmd(cmd)
# Perform the cherry-pick
- cmd = 'cd %s && git fetch %s %s && git cherry-pick FETCH_HEAD' % (project_path, fetch_url, fetch_ref)
+ cmd = 'cd %s && git cherry-pick FETCH_HEAD' % (project_path)
execute_cmd(cmd)
if not args.quiet:
print('')