Correctly translate all branches/tags/shas:
The code which raises an error if two elements try to install different versions of the same git repo currently works correctly for SHAs, or if a branch is specified first, followed by a SHA. However it fails if two branches are specified, because the shallow clone does not fetch all branch heads. This change correctly handles any combination of SHAs/branch-heads/tags. Change-Id: I501e94150ddeb41b79588816576a5d7a06fa92aa
This commit is contained in:
parent
c1bf047d39
commit
5b99028acf
@ -15,14 +15,24 @@ function install-os-service() {
|
|||||||
chown -R $user:$user /etc/$user
|
chown -R $user:$user /etc/$user
|
||||||
|
|
||||||
local svc_root=/opt/stack/$user
|
local svc_root=/opt/stack/$user
|
||||||
|
local git_dir="--git-dir $svc_root/.git"
|
||||||
|
|
||||||
if [ ! -e $svc_root ]; then
|
if [ ! -e $svc_root ]; then
|
||||||
git clone --depth=1 -b $branch $repo $svc_root
|
git clone --depth=1 -b $branch $repo $svc_root
|
||||||
[ -e $svc_root/tools/pip-requires ] && $pip_install -r $svc_root/tools/pip-requires
|
|
||||||
|
[ -e $svc_root/tools/pip-requires ] && pip install -r $svc_root/tools/pip-requires
|
||||||
$pip_install $svc_root
|
$pip_install $svc_root
|
||||||
else
|
else
|
||||||
expected_rev=$(git --git-dir $svc_root/.git rev-parse $branch)
|
if ! git $git_dir remote -v | grep $repo; then
|
||||||
actual_rev=$(git --git-dir $svc_root/.git show | head -1 | awk '{print $2}')
|
echo "ERROR: $svc_root exists and did not come from $repo"
|
||||||
if [ "$expected_rev" -ne "$actual_rev" ]; then
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# raise an error unless existing repo is at expected git-rev
|
||||||
|
actual_rev=$(git $git_dir show | head -1 | awk '{print $2}')
|
||||||
|
git $git_dir checkout $branch
|
||||||
|
expected_rev=$(git $git_dir show | head -1 | awk '{print $2}')
|
||||||
|
if [ "$expected_rev" != "$actual_rev" ]; then
|
||||||
echo "ERROR: $repo exists and is not on rev $branch"
|
echo "ERROR: $repo exists and is not on rev $branch"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user