Merge branch 'setup' into developer-setup

This commit is contained in:
Brad King 2012-04-26 15:43:29 -04:00
commit c9072f88cb
1 changed files with 37 additions and 11 deletions

View File

@ -37,17 +37,43 @@ die() {
cd "${BASH_SOURCE%/*}" && cd "${BASH_SOURCE%/*}" &&
# Load the project configuration. # Load the project configuration.
url=$(git config -f config --get stage.url) && fetchurl=$(git config -f config --get stage.url) &&
pushurl=$(git config -f config --get stage.pushurl || echo '') || pushurl_=$(git config -f config --get stage.pushurl || echo '') &&
remote=$(git config -f config --get stage.remote || echo 'stage') ||
die 'This project is not configured to use a topic stage.' die 'This project is not configured to use a topic stage.'
# Configure the remote if necessary. # Get current stage push URL.
if git config remote.stage.url >/dev/null; then pushurl=$(git config --get remote."$remote".pushurl ||
echo 'Topic stage already configured.' git config --get remote."$remote".url || echo '') &&
else
echo 'Setting up the topic stage...' && # Tell user about current configuration.
git remote add stage "$url" &&
if test -n "$pushurl"; then if test -n "$pushurl"; then
git config remote.stage.pushurl "$pushurl" echo 'Remote "'"$remote"'" is currently configured to push to
'"$pushurl"'
' &&
read -ep 'Reconfigure Topic Stage? [y/N]: ' ans &&
if [ "$ans" == "y" ] || [ "$ans" == "Y" ]; then
setup=1
else
setup=''
fi fi
fi || die 'Could not add the topic stage remote.' else
setup=1
fi
# Perform setup if necessary.
if test -n "$setup"; then
echo 'Setting up the topic stage...' &&
if test -z "$pushurl"; then
git remote add "$remote" "$fetchurl"
else
git config remote."$remote".url "$fetchurl"
fi &&
pushurl="${pushurl_}" &&
git config remote."$remote".pushurl "$pushurl" &&
echo 'Remote "'"$remote"'" is now configured to push to
'"$pushurl"'
'
fi || die 'Could not configure the topic stage remote.'