From fed4df87bf51404da3aeeecdbbf511fe27806fa6 Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Wed, 9 Aug 2017 10:13:57 -0400 Subject: [PATCH] ceph-volume-ansible-prs: fallback on sha1 to get remote branch Signed-off-by: Alfredo Deza --- ceph-volume-ansible-prs/build/build | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/ceph-volume-ansible-prs/build/build b/ceph-volume-ansible-prs/build/build index a81ab452..e5f70464 100644 --- a/ceph-volume-ansible-prs/build/build +++ b/ceph-volume-ansible-prs/build/build @@ -1,5 +1,6 @@ #!/bin/bash set -ex +env WORKDIR=$(mktemp -td tox.XXXXXXXXXX) # Find out the name of the remote branch from the Pull Request. This is otherwise not @@ -7,12 +8,24 @@ WORKDIR=$(mktemp -td tox.XXXXXXXXXX) # # 855ce630695ed9ca53c314b7e261ec3cc499787d refs/heads/wip-volume-tests BRANCH=`git ls-remote origin | grep $GIT_PREVIOUS_COMMIT | grep heads | cut -d '/' -f 3` +SHA=$GIT_PREVIOUS_COMMIT + +# sometimes, $GIT_PREVIOUS_COMMIT will not help grep from ls-remote, so we fallback +# to looking for GIT_COMMIT (e.g. if the branch has not been rebased to be the tip) +if [ -z "$BRANCH" ]; then + BRANCH=`git ls-remote origin | grep $GIT_COMMIT | grep heads | cut -d '/' -f 3` + SHA=$GIT_COMMIT +fi + +echo $BRANCH +echo $SHA + # the following two methods exist in scripts/build_utils.sh pkgs=( "tox" ) install_python_packages "pkgs[@]" -SHA=$GIT_COMMIT + cd src/ceph-volume/ceph_volume/tests/functional -- 2.47.3