Skip to content

Commit 1a52a02

Browse files
committed
support gerrit style refs/changes/... for branch names
To use a gerrit "branch" with devstack I would find the repo/remote and set it for the specific project. Example: https://review.openstack.org/2059 Would mean I update my localrc with the following settings: KEYSTONE_REPO=https://review.openstack.org/p/openstack/keystone KEYSTONE_BRANCH=refs/changes/59/2059/2 Change-Id: I0793415fb03cc08d1eb1a3faf1b8ec3e723beb31
1 parent ef4e536 commit 1a52a02

File tree

1 file changed

+28
-19
lines changed

1 file changed

+28
-19
lines changed

stack.sh

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -448,26 +448,35 @@ function git_clone {
448448
GIT_DEST=$2
449449
GIT_BRANCH=$3
450450

451-
# do a full clone only if the directory doesn't exist
452-
if [ ! -d $GIT_DEST ]; then
453-
git clone $GIT_REMOTE $GIT_DEST
454-
cd $2
455-
# This checkout syntax works for both branches and tags
456-
git checkout $GIT_BRANCH
457-
elif [[ "$RECLONE" == "yes" ]]; then
458-
# if it does exist then simulate what clone does if asked to RECLONE
451+
if echo $GIT_BRANCH | egrep -q "^refs"; then
452+
# If our branch name is a gerrit style refs/changes/...
453+
if [ ! -d $GIT_DEST ]; then
454+
git clone $GIT_REMOTE $GIT_DEST
455+
fi
459456
cd $GIT_DEST
460-
# set the url to pull from and fetch
461-
git remote set-url origin $GIT_REMOTE
462-
git fetch origin
463-
# remove the existing ignored files (like pyc) as they cause breakage
464-
# (due to the py files having older timestamps than our pyc, so python
465-
# thinks the pyc files are correct using them)
466-
find $GIT_DEST -name '*.pyc' -delete
467-
git checkout -f origin/$GIT_BRANCH
468-
# a local branch might not exist
469-
git branch -D $GIT_BRANCH || true
470-
git checkout -b $GIT_BRANCH
457+
git fetch $GIT_REMOTE $GIT_BRANCH && git checkout FETCH_HEAD
458+
else
459+
# do a full clone only if the directory doesn't exist
460+
if [ ! -d $GIT_DEST ]; then
461+
git clone $GIT_REMOTE $GIT_DEST
462+
cd $GIT_DEST
463+
# This checkout syntax works for both branches and tags
464+
git checkout $GIT_BRANCH
465+
elif [[ "$RECLONE" == "yes" ]]; then
466+
# if it does exist then simulate what clone does if asked to RECLONE
467+
cd $GIT_DEST
468+
# set the url to pull from and fetch
469+
git remote set-url origin $GIT_REMOTE
470+
git fetch origin
471+
# remove the existing ignored files (like pyc) as they cause breakage
472+
# (due to the py files having older timestamps than our pyc, so python
473+
# thinks the pyc files are correct using them)
474+
find $GIT_DEST -name '*.pyc' -delete
475+
git checkout -f origin/$GIT_BRANCH
476+
# a local branch might not exist
477+
git branch -D $GIT_BRANCH || true
478+
git checkout -b $GIT_BRANCH
479+
fi
471480
fi
472481
}
473482

0 commit comments

Comments
 (0)