ostbuild: Add -k option to git-mirror

libwacom's sourceforge git server was down...
This commit is contained in:
Colin Walters 2012-06-05 22:55:47 -04:00
parent e485bace01
commit c436f8ac61
2 changed files with 11 additions and 7 deletions

View File

@ -46,6 +46,8 @@ class OstbuildGitMirror(builtins.Builtin):
help="Don't perform a fetch if we have done so in the last N seconds")
parser.add_argument('--fetch', action='store_true',
help="Also do a git fetch for components")
parser.add_argument('-k', '--keep-going', action='store_true',
help="Don't exit on fetch failures")
parser.add_argument('components', nargs='*')
args = parser.parse_args(argv)
@ -95,6 +97,6 @@ class OstbuildGitMirror(builtins.Builtin):
continue
log("Running git fetch for %s" % (name, ))
vcs.fetch(self.mirrordir, keytype, uri, branch_or_tag)
vcs.fetch(self.mirrordir, keytype, uri, branch_or_tag, keep_going=args.keep_going)
builtins.register(OstbuildGitMirror)

View File

@ -141,13 +141,15 @@ def ensure_vcs_mirror(mirrordir, keytype, uri, branch):
f.close()
return mirror
def fetch(mirrordir, keytype, uri, branch):
def fetch(mirrordir, keytype, uri, branch, keep_going=False):
mirror = buildutil.get_mirrordir(mirrordir, keytype, uri)
last_fetch_path = get_lastfetch_path(mirrordir, keytype, uri, branch)
run_sync(['git', 'fetch'], cwd=mirror, log_initiation=False)
current_vcs_version = run_sync_get_output(['git', 'rev-parse', branch], cwd=mirror)
current_vcs_version = current_vcs_version.strip()
f = open(last_fetch_path, 'w')
f.write(current_vcs_version + '\n')
f.close()
current_vcs_version = run_sync_get_output(['git', 'rev-parse', branch], cwd=mirror,
none_on_error=keep_going)
if current_vcs_version is not None:
current_vcs_version = current_vcs_version.strip()
f = open(last_fetch_path, 'w')
f.write(current_vcs_version + '\n')
f.close()