Support post jobs by supporting rev checkout
Currently zuul-cloner does not support post jobs, as it does not know
what to checkout. This adds the ability on a per project basis to
specify a revision to be checked out. When specified zuul-cloner
will successfully check out the same repo as gerrit-git-prep.sh does
in post jobs.
Sample usage:
clonemap:
- name: openstack/neutron
dest: ./neu
- name: openstack/requirements
dest: ./reqs
export ZUUL_PROJECT="openstack/neutron"
export ZUUL_NEWREV="a2Fhc2Rma2FzZHNkZjhkYXM4OWZhc25pb2FzODkK"
export ZUUL_BRANCH="stable/liberty"
zuul-cloner -m map.yaml git://git.openstack.org $ZUUL_PROJECT \
openstack/requirements
This results with openstack/neutron checked out at rev a2Fhc2 and
openstack/requirements at 'heads/stable/liberty'
Change-Id: Ie9b03508a44f04adfbe2696cde136439ebffb9a6
diff --git a/tests/base.py b/tests/base.py
index 405caa0..7945a0b 100755
--- a/tests/base.py
+++ b/tests/base.py
@@ -1132,6 +1132,17 @@
zuul.merger.merger.reset_repo_to_head(repo)
repo.git.clean('-x', '-f', '-d')
+ def create_commit(self, project):
+ path = os.path.join(self.upstream_root, project)
+ repo = git.Repo(path)
+ repo.head.reference = repo.heads['master']
+ file_name = os.path.join(path, 'README')
+ with open(file_name, 'a') as f:
+ f.write('creating fake commit\n')
+ repo.index.add([file_name])
+ commit = repo.index.commit('Creating a fake commit')
+ return commit.hexsha
+
def ref_has_change(self, ref, change):
path = os.path.join(self.git_root, change.project)
repo = git.Repo(path)