diff --git a/src/ostbuild/pyostbuild/builtin_git_mirror.py b/src/ostbuild/pyostbuild/builtin_git_mirror.py index 0b7f0d58..2b78bcf1 100755 --- a/src/ostbuild/pyostbuild/builtin_git_mirror.py +++ b/src/ostbuild/pyostbuild/builtin_git_mirror.py @@ -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) diff --git a/src/ostbuild/pyostbuild/vcs.py b/src/ostbuild/pyostbuild/vcs.py index f47c283e..59d4e039 100755 --- a/src/ostbuild/pyostbuild/vcs.py +++ b/src/ostbuild/pyostbuild/vcs.py @@ -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()