From 05cd301f8b56b534459a8335f442dd3072a67b14 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Thu, 11 Apr 2013 14:10:45 -0700 Subject: [PATCH] Clone requirements into a tempdir. Git doesn't remove git repos with git clean, so the workspace checkout of the requirements repo was stale. Clone into a tempdir instead. Also, fix a traceback in the case that a new requirement is added. The loop wasn't short-circuiting as it should in that case. Print the git sha from the requirements repo to aid in debugging. Reorder imports. Change-Id: Id5a8e748a1fb353f2628a9c9fa291d6825d1046d Reviewed-on: https://review.openstack.org/26791 Reviewed-by: Clark Boylan Approved: James E. Blair Tested-by: Jenkins --- .../project-requirements-change.py | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/modules/jenkins/files/slave_scripts/project-requirements-change.py b/modules/jenkins/files/slave_scripts/project-requirements-change.py index 4cb86f1833..2c2fbc6dcb 100755 --- a/modules/jenkins/files/slave_scripts/project-requirements-change.py +++ b/modules/jenkins/files/slave_scripts/project-requirements-change.py @@ -15,11 +15,13 @@ # License for the specific language governing permissions and limitations # under the License. -import subprocess -import shlex -import sys -import pkg_resources import os +import pkg_resources +import shlex +import shutil +import subprocess +import sys +import tempfile def run_command(cmd): print(cmd) @@ -75,10 +77,14 @@ def main(): run_command("git checkout %s" % head) + reqroot = tempfile.mkdtemp() + reqdir = os.path.join(reqroot, "requirements") run_command("git clone https://review.openstack.org/p/openstack/" - "requirements --depth 1 .openstack-requirements") - os.chdir('.openstack-requirements') + "requirements --depth 1 %s" % reqdir) + os.chdir(reqdir) run_command("git checkout remotes/origin/%s" % branch) + print "requirements git sha: %s" % run_command( + "git rev-parse HEAD").strip() os_reqs = RequirementsList('openstack/requirements') os_reqs.read_all_requirements() @@ -90,6 +96,7 @@ def main(): if name not in os_reqs.reqs: print("Requirement %s not in openstack/requirements" % str(req)) failed = True + continue # pkg_resources.Requirement implements __eq__() but not __ne__(). # There is no implied relationship between __eq__() and __ne__() # so we must negate the result of == here instead of using !=. @@ -98,6 +105,7 @@ def main(): "value %s" % (str(req), str(os_reqs.reqs[name]))) failed = True + shutil.rmtree(reqroot) if failed or os_reqs.failed or head_reqs.failed or branch_reqs.failed: sys.exit(1) print("Updated requirements match openstack/requirements.")