summaryrefslogtreecommitdiffstats
path: root/Utilities/GitSetup/setup-gerrit
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-01-30 21:45:48 (GMT)
committerBrad King <brad.king@kitware.com>2017-01-30 21:45:48 (GMT)
commit3642d657b153f212eb119f1003e11c3079494630 (patch)
tree755564dc4cd08c1d48997a4cba158a539b117709 /Utilities/GitSetup/setup-gerrit
parenta6fda7bf4010051c2232d4ba6c64f310862a6471 (diff)
parent7e5ef9ca78f67c2f4def64408ce4c7ecc03917a7 (diff)
downloadCMake-3642d657b153f212eb119f1003e11c3079494630.zip
CMake-3642d657b153f212eb119f1003e11c3079494630.tar.gz
CMake-3642d657b153f212eb119f1003e11c3079494630.tar.bz2
Merge branch 'upstream-GitSetup' into developer-setup
* upstream-GitSetup: GitSetup 2016-12-13 (cd5ada6d)
Diffstat (limited to 'Utilities/GitSetup/setup-gerrit')
-rwxr-xr-xUtilities/GitSetup/setup-gerrit15
1 files changed, 10 insertions, 5 deletions
diff --git a/Utilities/GitSetup/setup-gerrit b/Utilities/GitSetup/setup-gerrit
index 9e8fa62..6d46e3c 100755
--- a/Utilities/GitSetup/setup-gerrit
+++ b/Utilities/GitSetup/setup-gerrit
@@ -28,6 +28,7 @@
# gerrit.pushurl = Review site push URL with "$username" placeholder
# gerrit.remote = Gerrit remote name, if not "gerrit"
# gerrit.url = Gerrit project URL, if not "$site/p/$project"
+# optionally with "$username" placeholder
die() {
echo 1>&2 "$@" ; exit 1
@@ -39,11 +40,12 @@ cd "${BASH_SOURCE%/*}" &&
# Load the project configuration.
site=$(git config -f config --get gerrit.site) &&
project=$(git config -f config --get gerrit.project) &&
-pushurl_=$(git config -f config --get gerrit.pushurl) &&
remote=$(git config -f config --get gerrit.remote ||
echo "gerrit") &&
-fetchurl=$(git config -f config --get gerrit.url ||
- echo "$site/p/$project") ||
+fetchurl_=$(git config -f config --get gerrit.url ||
+ echo "$site/p/$project") &&
+pushurl_=$(git config -f config --get gerrit.pushurl ||
+ git config -f config --get gerrit.url) ||
die 'This project is not configured to use Gerrit.'
# Get current gerrit push URL.
@@ -67,7 +69,7 @@ else
'"$project"' changes must be pushed to our Gerrit Code Review site:
- '"$fetchurl"'
+ '"$site/p/$project"'
Register a Gerrit account and select a username (used below).
You will need an OpenID:
@@ -96,13 +98,16 @@ Add your SSH public keys at
if test -z "$gu"; then
gu="$USER"
fi &&
+ fetchurl="${fetchurl_/\$username/$gu}" &&
if test -z "$pushurl"; then
git remote add "$remote" "$fetchurl"
else
git config remote."$remote".url "$fetchurl"
fi &&
pushurl="${pushurl_/\$username/$gu}" &&
- git config remote."$remote".pushurl "$pushurl" &&
+ if test "$pushurl" != "$fetchurl"; then
+ git config remote."$remote".pushurl "$pushurl"
+ fi &&
echo 'Remote "'"$remote"'" is now configured to push to
'"$pushurl"'