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
This commit is contained in:
Jesse Andrews 2011-12-05 13:38:29 -08:00
parent ef4e5367d2
commit 1a52a02f10

View file

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