Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 250b7369 authored by Chirayu Desai's avatar Chirayu Desai Committed by Gerrit Code Review
Browse files

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
parent 8550418a
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -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,6 +120,7 @@ def execute_cmd(cmd):
    if os.system(cmd):
        if not args.verbose:
            print('\nCommand that failed:\n%s' % cmd)
        if not can_fail:
             sys.exit(1)

# Verifies whether pathA is a subdirectory (or the same) as 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: