From dc077549ec19516662fa6ab68b7aada113ba04ee Mon Sep 17 00:00:00 2001 From: Chirayu Desai Date: Fri, 23 Jan 2015 23:53:48 +0530 Subject: repopick: Allow the github fetch to fail * This is optional and done to save gerrit server bandwidth, however it may fail in cases where the 'github' remote is a mirror which doesn't sync the changes. * Let it try fetching from gerrit if fetching from github fails. Change-Id: I6d183ff83572d817d78633280d8b20e3efdaf8f0 --- tools/repopick.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'tools/repopick.py') diff --git a/tools/repopick.py b/tools/repopick.py index b965b4c..679fae4 100755 --- a/tools/repopick.py +++ b/tools/repopick.py @@ -108,10 +108,10 @@ def which(program): return None # Simple wrapper for os.system() that: -# - exits on error +# - exits on error if !can_fail # - prints out the command if --verbose # - suppresses all output if --quiet -def execute_cmd(cmd): +def execute_cmd(cmd, can_fail=False): if args.verbose: print('Executing: %s' % cmd) if args.quiet: @@ -120,7 +120,8 @@ def execute_cmd(cmd): if os.system(cmd): if not args.verbose: print('\nCommand that failed:\n%s' % cmd) - sys.exit(1) + if not can_fail: + sys.exit(1) # Verifies whether pathA is a subdirectory (or the same) as pathB def is_pathA_subdir_of_pathB(pathA, pathB): @@ -392,7 +393,7 @@ for changeps in args.change_number: cmd = 'cd %s && git pull --no-edit github %s' % (project_path, fetch_ref) else: cmd = 'cd %s && git fetch github %s' % (project_path, fetch_ref) - execute_cmd(cmd) + execute_cmd(cmd, True) # Check if it worked FETCH_HEAD = '%s/.git/FETCH_HEAD' % project_path if os.stat(FETCH_HEAD).st_size == 0: -- cgit v1.1