Merge "check out a specific reference when cloning the repo"

This commit is contained in:
Jenkins
2017-01-31 11:19:21 +00:00
committed by Gerrit Code Review
2 changed files with 29 additions and 23 deletions

View File

@@ -231,7 +231,7 @@ def validate_releases(deliverable_info, zuul_layout,
# Ensure we have a local copy of the repository so we # Ensure we have a local copy of the repository so we
# can scan for values that are more difficult to get # can scan for values that are more difficult to get
# remotely. # remotely.
gitutils.clone_repo(workdir, project['repo']) gitutils.clone_repo(workdir, project['repo'], project['hash'])
# Check that the sdist name and tarball-base name match. # Check that the sdist name and tarball-base name match.
if link_mode == 'tarball': if link_mode == 'tarball':

View File

@@ -64,30 +64,36 @@ def tag_exists(repo, ref):
return links.link_exists(url) return links.link_exists(url)
def clone_repo(workdir, repo): def clone_repo(workdir, repo, ref=None):
"Check out the code." "Check out the code."
dest = os.path.join(workdir, repo) dest = os.path.join(workdir, repo)
if os.path.exists(dest): if not os.path.exists(dest):
return cmd = [
cmd = [ 'zuul-cloner',
'zuul-cloner', '--workspace', workdir,
'--workspace', workdir, ]
] cache_dir = os.environ.get('ZUUL_CACHE_DIR', '/opt/git')
cache_dir = os.environ.get('ZUUL_CACHE_DIR', '/opt/git') if cache_dir and os.path.exists(cache_dir):
if cache_dir and os.path.exists(cache_dir): cmd.extend(['--cache-dir', cache_dir])
cmd.extend(['--cache-dir', cache_dir]) cmd.extend([
cmd.extend([ 'git://git.openstack.org',
'git://git.openstack.org', repo,
repo, ])
]) subprocess.check_call(cmd)
subprocess.check_call(cmd) # Force an update, just in case the local version is still out of
# Force an update, just in case the local version is still out of # date.
# date. print('Updating newly cloned repository in %s' % dest)
print('Updating newly cloned repository in %s' % dest) subprocess.check_call(
subprocess.check_call( ['git', 'fetch', '-v', '--tags'],
['git', 'fetch', '-v', '--tags'], cwd=dest,
cwd=dest, )
) # If we were given some sort of reference, check that out.
if ref:
print('Updating %s to %s' % (repo, ref))
subprocess.check_call(
['git', 'checkout', ref],
cwd=dest,
)
def sha_for_tag(workdir, repo, version): def sha_for_tag(workdir, repo, version):