Update gerrit-git-prep to infra's
This provides better support for zuul merger parameters
Change-Id: I9b8f5b03a682374c67532784adfbf94176316013
diff --git a/etc/turbo-hipster/config.yaml b/etc/turbo-hipster/config.yaml
index ad86e66..062848e 100644
--- a/etc/turbo-hipster/config.yaml
+++ b/etc/turbo-hipster/config.yaml
@@ -1,6 +1,5 @@
zuul_server:
gerrit_site: http://review.openstack.org
- zuul_site: http://119.9.13.90
git_origin: git://git.openstack.org/
gearman_host: 119.9.13.90
gearman_port: 4730
diff --git a/tests/etc/config.yaml b/tests/etc/config.yaml
index e43b024..e06cbdb 100644
--- a/tests/etc/config.yaml
+++ b/tests/etc/config.yaml
@@ -1,18 +1,19 @@
zuul_server:
- git_url: /home/josh/var/lib/zuul/git/
- gearman_host: localhost
- gearman_port: 0
+ gerrit_site: http://review.openstack.org
+ git_origin: git://git.openstack.org/
+ gearman_host: localhost
+ gearman_port: 0
debug_log: /home/josh/var/log/turbo-hipster/debug.log
jobs_working_dir: /home/josh/var/lib/turbo-hipster/jobs
git_working_dir: /home/josh/var/lib/turbo-hipster/git
pip_download_cache: /home/josh/var/cache/pip
plugins:
- - name: real_db_upgrade
- datasets_dir": /home/josh/var/lib/turbo-hipster/datasets
- job: real-db-upgrade_nova_mysql
+ - name: real_db_upgrade
+ datasets_dir": /home/josh/var/lib/turbo-hipster/datasets
+ job: real-db-upgrade_nova_mysql
publish_logs:
- type: local
- path: /home/josh/var/www/results/
- prepend_url: http://localhost/results/
+ type: local
+ path: /home/josh/var/www/results/
+ prepend_url: http://localhost/results/
diff --git a/tests/etc/default-config.yaml b/tests/etc/default-config.yaml
index b2e17dc..34d3dca 100644
--- a/tests/etc/default-config.yaml
+++ b/tests/etc/default-config.yaml
@@ -1,6 +1,5 @@
zuul_server:
gerrit_site: http://review.openstack.org
- zuul_site: http://119.9.13.90
git_origin: git://git.openstack.org/
gearman_host: localhost
gearman_port: 0
diff --git a/tests/etc/jjb-config.yaml b/tests/etc/jjb-config.yaml
index bcc341c..ce96702 100644
--- a/tests/etc/jjb-config.yaml
+++ b/tests/etc/jjb-config.yaml
@@ -1,6 +1,5 @@
zuul_server:
gerrit_site: http://review.openstack.org
- zuul_site: http://119.9.13.90
git_origin: git://git.openstack.org/
gearman_host: localhost
gearman_port: 0
diff --git a/tests/etc/shutdown-config.yaml b/tests/etc/shutdown-config.yaml
index 9175873..56162e4 100644
--- a/tests/etc/shutdown-config.yaml
+++ b/tests/etc/shutdown-config.yaml
@@ -1,6 +1,5 @@
zuul_server:
gerrit_site: http://review.openstack.org
- zuul_site: http://119.9.13.90
git_origin: git://git.openstack.org/
gearman_host: localhost
gearman_port: 0
diff --git a/turbo_hipster/lib/gerrit-git-prep.sh b/turbo_hipster/lib/gerrit-git-prep.sh
index 16b4aaf..1b9e546 100755
--- a/turbo_hipster/lib/gerrit-git-prep.sh
+++ b/turbo_hipster/lib/gerrit-git-prep.sh
@@ -1,10 +1,9 @@
#!/bin/bash -e
-# Stolen from http://git.openstack.org/cgit/openstack-infra/config/plain/modules/jenkins/files/slave_scripts/gerrit-git-prep.sh but has been hacked to be AWESOME!
+# Stolen from http://git.openstack.org/cgit/openstack-infra/config/plain/modules/jenkins/files/slave_scripts/gerrit-git-prep.sh
GERRIT_SITE=$1
-ZUUL_SITE=$2
-GIT_ORIGIN=$3
+GIT_ORIGIN=$2
if [ -z "$GERRIT_SITE" ]
then
@@ -12,9 +11,9 @@
exit 1
fi
-if [ -z "$ZUUL_SITE" ]
+if [ -z "$ZUUL_URL" ]
then
- echo "The zuul site name (eg 'http://zuul.openstack.org') must be the second argument."
+ echo "The ZUUL_URL must be provided."
exit 1
fi
@@ -27,8 +26,16 @@
if [ -z "$ZUUL_REF" ]
then
- echo "This job may only be triggered by Zuul."
- exit 1
+ if [ -n "$BRANCH" ]
+ then
+ echo "No ZUUL_REF so using requested branch $BRANCH from origin."
+ ZUUL_REF=$BRANCH
+ # use the origin since zuul mergers have outdated branches
+ ZUUL_URL=$GIT_ORIGIN
+ else
+ echo "Provide either ZUUL_REF or BRANCH in the calling enviromnent."
+ exit 1
+ fi
fi
if [ ! -z "$ZUUL_CHANGE" ]
@@ -48,8 +55,6 @@
git clone $GIT_ORIGIN/$ZUUL_PROJECT .
fi
fi
-git checkout master
-git pull
git remote set-url origin $GIT_ORIGIN/$ZUUL_PROJECT
# attempt to work around bugs 925790 and 1229352
@@ -66,25 +71,25 @@
git clean -x -f -d -q
fi
-if [ -z "$ZUUL_NEWREV" ]
+if echo "$ZUUL_REF" | grep -q ^refs/tags/
then
- git fetch $ZUUL_SITE/p/$ZUUL_PROJECT $ZUUL_REF
+ git fetch --tags $ZUUL_URL/$ZUUL_PROJECT
+ git checkout $ZUUL_REF
+ git reset --hard $ZUUL_REF
+elif [ -z "$ZUUL_NEWREV" ]
+then
+ git fetch $ZUUL_URL/$ZUUL_PROJECT $ZUUL_REF
git checkout FETCH_HEAD
git reset --hard FETCH_HEAD
- if ! git clean -x -f -d -q ; then
- sleep 1
- git clean -x -f -d -q
- fi
else
git checkout $ZUUL_NEWREV
git reset --hard $ZUUL_NEWREV
- if ! git clean -x -f -d -q ; then
- sleep 1
- git clean -x -f -d -q
- fi
fi
-git branch -D working || true
-git checkout -b working
+
+if ! git clean -x -f -d -q ; then
+ sleep 1
+ git clean -x -f -d -q
+fi
if [ -f .gitmodules ]
then
diff --git a/turbo_hipster/lib/models.py b/turbo_hipster/lib/models.py
index 742fa54..b5c6b8e 100644
--- a/turbo_hipster/lib/models.py
+++ b/turbo_hipster/lib/models.py
@@ -192,7 +192,7 @@
cmd = os.path.join(os.path.join(os.path.dirname(__file__),
'gerrit-git-prep.sh'))
cmd += ' ' + self.worker_server.config['zuul_server']['gerrit_site']
- cmd += ' ' + self.worker_server.config['zuul_server']['zuul_site']
+ cmd += ' ' + self.worker_server.config['zuul_server']['git_origin']
utils.execute_to_log(cmd, self.shell_output_log, env=git_args,
cwd=local_path)
self.git_path = local_path