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
main
Jesse Andrews 13 years ago
parent ef4e5367d2
commit 1a52a02f10

@ -448,26 +448,35 @@ function git_clone {
GIT_DEST=$2
GIT_BRANCH=$3
# do a full clone only if the directory doesn't exist
if [ ! -d $GIT_DEST ]; then
git clone $GIT_REMOTE $GIT_DEST
cd $2
# This checkout syntax works for both branches and tags
git checkout $GIT_BRANCH
elif [[ "$RECLONE" == "yes" ]]; then
# if it does exist then simulate what clone does if asked to RECLONE
if echo $GIT_BRANCH | egrep -q "^refs"; then
# If our branch name is a gerrit style refs/changes/...
if [ ! -d $GIT_DEST ]; then
git clone $GIT_REMOTE $GIT_DEST
fi
cd $GIT_DEST
# set the url to pull from and fetch
git remote set-url origin $GIT_REMOTE
git fetch origin
# remove the existing ignored files (like pyc) as they cause breakage
# (due to the py files having older timestamps than our pyc, so python
# thinks the pyc files are correct using them)
find $GIT_DEST -name '*.pyc' -delete
git checkout -f origin/$GIT_BRANCH
# a local branch might not exist
git branch -D $GIT_BRANCH || true
git checkout -b $GIT_BRANCH
git fetch $GIT_REMOTE $GIT_BRANCH && git checkout FETCH_HEAD
else
# do a full clone only if the directory doesn't exist
if [ ! -d $GIT_DEST ]; then
git clone $GIT_REMOTE $GIT_DEST
cd $GIT_DEST
# This checkout syntax works for both branches and tags
git checkout $GIT_BRANCH
elif [[ "$RECLONE" == "yes" ]]; then
# if it does exist then simulate what clone does if asked to RECLONE
cd $GIT_DEST
# set the url to pull from and fetch
git remote set-url origin $GIT_REMOTE
git fetch origin
# remove the existing ignored files (like pyc) as they cause breakage
# (due to the py files having older timestamps than our pyc, so python
# thinks the pyc files are correct using them)
find $GIT_DEST -name '*.pyc' -delete
git checkout -f origin/$GIT_BRANCH
# a local branch might not exist
git branch -D $GIT_BRANCH || true
git checkout -b $GIT_BRANCH
fi
fi
}

Loading…
Cancel
Save