Skip to content
This repository has been archived by the owner on Sep 10, 2021. It is now read-only.

Commit

Permalink
setup-gerrit: Allow ssh-only repo URLs
Browse files Browse the repository at this point in the history
Honor the $username placeholder in the 'gerrit.url' configuration value.
Configure a separate pushurl only if it is different from the main url.
  • Loading branch information
bradking committed May 18, 2012
1 parent b7daff9 commit d2d17f5
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions setup-gerrit
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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:
Expand Down Expand Up @@ -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"'
Expand Down

0 comments on commit d2d17f5

Please sign in to comment.