Merge "add safe_clone_repo function"
This commit is contained in:
@@ -321,13 +321,8 @@ def clone_deliverable(deliverable_info, workdir, mk_warning, mk_error):
|
|||||||
if project['repo'] in cloned:
|
if project['repo'] in cloned:
|
||||||
continue
|
continue
|
||||||
cloned.add(project['repo'])
|
cloned.add(project['repo'])
|
||||||
try:
|
if not gitutils.safe_clone_repo(workdir, project['repo'],
|
||||||
gitutils.clone_repo(workdir, project['repo'])
|
project['hash'], mk_error):
|
||||||
except Exception as err:
|
|
||||||
mk_error('Could not clone repository %s at %s: %s' % (
|
|
||||||
project['repo'], project['hash'], err))
|
|
||||||
# No point in running extra checks if we can't
|
|
||||||
# clone the repository.
|
|
||||||
ok = False
|
ok = False
|
||||||
return ok
|
return ok
|
||||||
|
|
||||||
@@ -472,16 +467,8 @@ def validate_releases(deliverable_info, zuul_projects,
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
|
||||||
# Ensure we have a local copy of the repository so we
|
if not gitutils.safe_clone_repo(workdir, project['repo'],
|
||||||
# can scan for values that are more difficult to get
|
project['hash'], mk_error):
|
||||||
# remotely.
|
|
||||||
try:
|
|
||||||
gitutils.clone_repo(workdir, project['repo'], project['hash'])
|
|
||||||
except Exception as err:
|
|
||||||
mk_error('Could not clone repository %s at %s: %s' % (
|
|
||||||
project['repo'], project['hash'], err))
|
|
||||||
# No point in running extra checks if we can't
|
|
||||||
# clone the repository.
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Report if the SHA exists or not (an error if it
|
# Report if the SHA exists or not (an error if it
|
||||||
@@ -773,17 +760,8 @@ def validate_stable_branches(deliverable_info, workdir,
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
for project in known_releases[location]['projects']:
|
for project in known_releases[location]['projects']:
|
||||||
# Ensure we have a local copy of the repository so we
|
if not gitutils.safe_clone_repo(workdir, project['repo'],
|
||||||
# can scan for values that are more difficult to get
|
project['hash'], mk_error):
|
||||||
# remotely.
|
|
||||||
try:
|
|
||||||
gitutils.clone_repo(workdir, project['repo'],
|
|
||||||
project['hash'])
|
|
||||||
except Exception as err:
|
|
||||||
mk_error('Could not clone repository %s at %s: %s' % (
|
|
||||||
project['repo'], project['hash'], err))
|
|
||||||
# No point in running extra checks if we can't
|
|
||||||
# clone the repository.
|
|
||||||
continue
|
continue
|
||||||
_require_gitreview(workdir, project['repo'], mk_error)
|
_require_gitreview(workdir, project['repo'], mk_error)
|
||||||
elif branch_mode == 'tagless':
|
elif branch_mode == 'tagless':
|
||||||
@@ -806,16 +784,7 @@ def validate_stable_branches(deliverable_info, workdir,
|
|||||||
)
|
)
|
||||||
# We can't clone the location if it isn't a SHA.
|
# We can't clone the location if it isn't a SHA.
|
||||||
continue
|
continue
|
||||||
# Ensure we have a local copy of the repository so we
|
if not gitutils.safe_clone_repo(workdir, repo, loc, mk_error):
|
||||||
# can scan for values that are more difficult to get
|
|
||||||
# remotely.
|
|
||||||
try:
|
|
||||||
gitutils.clone_repo(workdir, repo, loc)
|
|
||||||
except Exception as err:
|
|
||||||
mk_error('Could not clone repository %s at %s: %s' % (
|
|
||||||
repo, loc, err))
|
|
||||||
# No point in running extra checks if we can't
|
|
||||||
# clone the repository.
|
|
||||||
continue
|
continue
|
||||||
_require_gitreview(workdir, repo, mk_error)
|
_require_gitreview(workdir, repo, mk_error)
|
||||||
if not gitutils.commit_exists(workdir, repo, loc):
|
if not gitutils.commit_exists(workdir, repo, loc):
|
||||||
|
|||||||
@@ -109,6 +109,20 @@ def clone_repo(workdir, repo, ref=None, branch=None):
|
|||||||
subprocess.check_call(cmd)
|
subprocess.check_call(cmd)
|
||||||
|
|
||||||
|
|
||||||
|
def safe_clone_repo(workdir, repo, ref, mk_error):
|
||||||
|
"""Ensure we have a local copy of the repository so we
|
||||||
|
can scan for values that are more difficult to get
|
||||||
|
remotely.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
clone_repo(workdir, repo, ref)
|
||||||
|
except Exception as err:
|
||||||
|
mk_error('Could not clone repository %s at %s: %s' % (
|
||||||
|
repo, ref, err))
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def sha_for_tag(workdir, repo, version):
|
def sha_for_tag(workdir, repo, version):
|
||||||
"""Return the SHA for a given tag
|
"""Return the SHA for a given tag
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user