Commit 6257ab9f authored by Brad King's avatar Brad King Committed by Code Review

Merge topic 'cleanup-setup-scripts' into master

ed78e674 SetupForDevelopment: Revise entire process
727a25eb SetupForDevelopment: Remove topic stage
parents 97b66684 ed78e674
#!/usr/bin/env bash
# This script makes optional suggestions for working with git.
if test "$(git config color.ui)" != "auto"; then
cat << EOF
You may want to enable color output from Git commands with
egrep-q() {
egrep "$@" >/dev/null 2>/dev/null
}
git config --global color.ui auto
if test -z "$(git config --get color.ui)"; then
echo '
One may enable color output from Git commands with
EOF
git config --global color.ui auto
'
fi
if ! bash -i -c 'echo $PS1' | grep -q '__git_ps1'; then
cat << EOF
if ! bash -i -c 'echo $PS1' | egrep-q '__git_ps1'; then
echo '
A dynamic, informative Git shell prompt can be obtained by sourcing the git
bash-completion script in your ~/.bashrc. Set the PS1 environmental variable as
suggested in the comments at the top of the bash-completion script. You may
need to install the bash-completion package from your distribution to obtain the
script.
EOF
need to install the bash-completion package from your distribution to obtain it.
'
fi
if ! git config merge.tool >/dev/null; then
cat << EOF
A merge tool can be configured with
if test -z "$(git config --get merge.tool)"; then
echo '
One may configure Git to load a merge tool with
git config merge.tool <toolname>
For more information, see
git help mergetool
EOF
See "git help mergetool" for more information.
'
fi
echo "Done."
#!/usr/bin/env bash
# Run this script to set up the git repository to push to the Gerrit code review
# system.
# Run this script to set up the git repository to push to the Gerrit code
# review system.
die() {
echo 'Failure during Gerrit setup.' 1>&2
echo '----------------------------' 1>&2
echo '' 1>&2
echo "$@" 1>&2
exit 1
echo 1>&2 "$@" ; exit 1
}
# Centralize project variables for each script
project="VTK"
gerrit_user() {
read -ep "Enter your gerrit user (set in Gerrit Settings/Profile) [$USER]: " gu
if [ "$gu" == "" ]; then
# Use current user name.
gu=$USER
fi
echo -e "\nConfiguring 'gerrit' remote with user '$gu'..."
if git config remote.gerrit.url >/dev/null; then
# Correct the remote url
git remote set-url gerrit $gu@review.source.kitware.com:${project} || \
die "Could not amend gerrit remote."
else
# Add a new one
git remote add gerrit $gu@review.source.kitware.com:${project} || \
die "Could not add gerrit remote."
fi
cat << EOF
# Make sure we are inside the repository.
cd "${BASH_SOURCE%/*}" &&
For more information on Gerrit usage, see
# Get current gerrit push URL.
pushurl=$(git config --get remote.gerrit.pushurl ||
git config --get remote.gerrit.url || echo '') &&
http://public.kitware.com/Wiki/ITK/Gerrit
EOF
}
# Tell user about current configuration.
if test -n "$pushurl"; then
echo 'Remote "gerrit" is currently configured to push to
# Make sure we are inside the repository.
cd "$(echo "$0"|sed 's/[^/]*$//')"
if git config remote.gerrit.url >/dev/null; then
echo "Gerrit was already configured. The configured remote URL is:"
echo
git config remote.gerrit.url
echo
read -ep "Is the username correct? [Y/n]: " correct
if [ "$correct" == "n" ] || [ "$correct" == "N" ]; then
gerrit_user
'"$pushurl"'
' &&
read -ep 'Reconfigure Gerrit? [y/N]: ' ans &&
if [ "$ans" == "y" ] || [ "$ans" == "Y" ]; then
setup=1
else
setup=''
fi
else
cat << EOF
Gerrit is a code review system that works with Git.
echo 'Remote "gerrit" is not yet configured.
In order to use Gerrit, an account must be registered at the review site:
VTK changes must be pushed to our Gerrit Code Review site:
http://review.source.kitware.com/p/${project}
http://review.source.kitware.com/p/VTK
In order to register you need an OpenID
Register a Gerrit account and select a username (used below).
You will need an OpenID:
http://openid.net/get-an-openid/
' &&
read -ep 'Configure Gerrit? [Y/n]: ' ans &&
if [ "$ans" == "n" ] || [ "$ans" == "N" ]; then
exit 0
else
setup=1
fi
fi &&
EOF
gerrit_user
fi
# Perform setup if necessary.
if test -n "$setup"; then
echo 'Sign-in to Gerrit to get/set your username at
read -ep "Would you like to verify authentication to Gerrit? [y/N]: " ans
if [ "$ans" == "y" ] || [ "$ans" == "Y" ]; then
echo
echo "Fetching from gerrit to test SSH key configuration (Settings/SSH Public Keys)"
git fetch gerrit ||
die "Could not fetch gerrit remote. You need to upload your public SSH key to Gerrit."
echo "Done."
fi
http://review.source.kitware.com/#/settings
echo -e "\nConfiguring GerritId hook..."
if git config hooks.GerritId >/dev/null; then
echo "GerritId hook already configured."
else
cat << EOF
This hook automatically add a "Change-Id" footer to commit messages
to make interaction with Gerrit easier.
To disable this feature, run
Add your SSH public keys at
http://review.source.kitware.com/#/settings/ssh-keys
' &&
read -ep "Gerrit username? [$USER]: " gu &&
if test -z "$gu"; then
gu="$USER"
fi &&
fetchurl='http://review.source.kitware.com/p/VTK' &&
if test -z "$pushurl"; then
git remote add gerrit "$fetchurl"
else
git config remote.gerrit.url "$fetchurl"
fi &&
pushurl="$gu@review.source.kitware.com:VTK" &&
git config remote.gerrit.pushurl "$pushurl" &&
echo 'Remote "gerrit" is now configured to push to
'"$pushurl"'
'
fi &&
# Optionally test Gerrit access.
if test -n "$pushurl"; then
read -ep 'Test access to Gerrit (SSH)? [y/N]: ' ans &&
if [ "$ans" == "y" ] || [ "$ans" == "Y" ]; then
echo -n 'Testing Gerrit access by SSH...'
if git ls-remote --heads "$pushurl" >/dev/null; then
echo 'passed.'
else
echo 'failed.' &&
die 'Could not access Gerrit. Add your SSH public keys at
http://review.source.kitware.com/#/settings/ssh-keys
'
fi
fi
fi &&
# Set up GerritId hook.
hook=$(git config --get hooks.GerritId || echo '') &&
if test -z "$hook"; then
echo '
Enabling GerritId hook to add a "Change-Id" footer to commit
messages for interaction with Gerrit. Run
git config hooks.GerritId false
EOF
to disable this feature (but you will be on your own).' &&
git config hooks.GerritId true
echo "Done."
else
echo 'GerritId hook already configured to "'"$hook"'".'
fi
#!/usr/bin/env bash
# Centralize project variables for each script
project="VTK"
projectUrl="vtk.org"
GIT=git
GITCONFIG="${GIT} config"
echo "Setting up useful Git aliases..." &&
# General aliases that could be global
${GITCONFIG} alias.pullall "!sh -c \"git pull && git submodule update --init\""
${GITCONFIG} alias.prepush 'log --graph --stat origin/master..'
git config alias.pullall "!bash -c \"git pull && git submodule update --init\"" &&
git config alias.prepush 'log --graph --stat origin/master..' &&
# Staging aliases
stage_deprecated="The stage aliases have been deprecated. Please use Gerrit."
${GITCONFIG} alias.stage-cmd "!sh -c \"echo ${stage_deprecated}\""
${GITCONFIG} alias.stage-push "!sh -c \"echo ${stage_deprecated}\""
${GITCONFIG} alias.stage-branch "!sh -c \"echo ${stage_deprecated}\""
${GITCONFIG} alias.stage-merge "!sh -c \"echo ${stage_deprecated}\""
stage_deprecated="The stage aliases have been deprecated. Please use Gerrit." &&
git config alias.stage-cmd "!sh -c \"echo ${stage_deprecated}\"" &&
git config alias.stage-push "!sh -c \"echo ${stage_deprecated}\"" &&
git config alias.stage-branch "!sh -c \"echo ${stage_deprecated}\"" &&
git config alias.stage-merge "!sh -c \"echo ${stage_deprecated}\"" &&
# Alias to push the current topic branch to Gerrit
${GITCONFIG} alias.gerrit-push "!bash Utilities/Scripts/git-gerrit-push"
git config alias.gerrit-push "!bash Utilities/Scripts/git-gerrit-push" &&
true
#!/usr/bin/env bash
# Run this script to set up the git hooks for committing changes
# Run this script to set up the git hooks for committing changes to VTK.
# For more information, see:
# http://public.kitware.com/Wiki/Git/Hooks
# http://www.vtk.org/Wiki/Git/Hooks
die() {
echo 'Failure during hook setup.' 1>&2
echo '--------------------------' 1>&2
echo '' 1>&2
echo "$@" 1>&2
exit 1
egrep-q() {
egrep "$@" >/dev/null 2>/dev/null
}
# Centralize project variables for each script
project="VTK"
projectUrl="vtk.org"
u=$(cd "$(echo "$0"|sed 's/[^/]*$//')"; pwd)
cd "$u/../../.git/hooks"
# We need to have a git repository to do a pull.
if ! test -d ./.git; then
git init || die "Could not run git init."
fi
die() {
echo 1>&2 "$@" ; exit 1
}
# Grab the hooks.
# Use the local hooks if possible.
echo "Pulling the hooks..."
if GIT_DIR=.. git for-each-ref refs/remotes/origin/hooks 2>/dev/null | \
grep -q '\<refs/remotes/origin/hooks$'; then
git fetch .. remotes/origin/hooks
echo 'Setting up git hooks...' &&
cd "${BASH_SOURCE%/*}" &&
git_dir=$(git rev-parse --git-dir) &&
cd "$git_dir/hooks" &&
if ! test -e .git; then
git init -q || die 'Could not run git init for hooks.'
fi &&
if GIT_DIR=.. git for-each-ref refs/remotes/origin/hooks 2>/dev/null |
egrep-q 'refs/remotes/origin/hooks$'; then
git fetch -q .. remotes/origin/hooks
else
git fetch http://${projectUrl}/${project}.git hooks
git fetch -q http://vtk.org/VTK.git hooks
fi &&
git reset --hard FETCH_HEAD || die "Failed to install hooks"
cd ../..
echo "Done."
git reset -q --hard FETCH_HEAD || die 'Failed to install hooks'
#!/usr/bin/env bash
# Run this script to set up the topic stage for pushing changes.
die() {
echo 'Failure during topic stage setup.' 1>&2
echo '---------------------------------' 1>&2
echo '' 1>&2
echo "$@" 1>&2
exit 1
}
# Centralize project variables for each script
project="VTK"
projectUrl="vtk.org"
# Make sure we are inside the repository.
cd "$(echo "$0"|sed 's/[^/]*$//')"
if git config remote.stage.url >/dev/null; then
echo "Topic stage remote was already configured."
else
echo "Configuring the topic stage remote..."
git remote add stage git://${projectUrl}/stage/${project}.git || \
die "Could not add the topic stage remote."
git config remote.stage.pushurl git@${projectUrl}:stage/${project}.git
fi
read -ep "Do you want to test push access for ${project}? [y/N]: " access
if [ "$access" == "y" ] || [ "$access" == "Y" ]; then
echo "Configuring push urls..."
if [ "`git config remote.origin.url`" == "git://${projectUrl}/${project}.git" ]; then
git config remote.origin.pushurl git@${projectUrl}:${project}.git
fi
echo "Testing ssh capabilities..."
git ls-remote git@${projectUrl}:stage/${project}.git refs/heads/master || \
die "SSH test to git@${projectUrl} failed. You may need to request access at:
https://www.kitware.com/Admin/SendPassword.cgi
Note that push access to the stage/${project} is separate to Gerrit.
"
echo "Test successful! ${project} push access confirmed. Summary of project access:"
echo
# This command queries gitolite for your access privileges
ssh git@${projectUrl} info
fi
echo "Done."
......@@ -2,14 +2,6 @@
# Run this script to set up basic user information.
die() {
echo 'Failure during user information setup.' 1>&2
echo '--------------------------------------' 1>&2
echo '' 1>&2
echo "$@" 1>&2
exit 1
}
setup_user() {
read -ep "Please enter your full name, such as 'John Doe': " name
echo "Setting name to '$name'"
......@@ -19,6 +11,8 @@ setup_user() {
git config user.email "$email"
}
echo "Checking basic user information..."
# Added some logic to introduce yourself to Git.
gitName=$(git config user.name)
gitEmail=$(git config user.email)
......
#!/usr/bin/env bash
# Run this script to set up development with git.
die() {
echo 'Failure during git development setup' 1>&2
echo '------------------------------------' 1>&2
echo '' 1>&2
echo "$@" 1>&2
exit 1
}
# Make sure we are inside the repository.
cd "$(echo "$0"|sed 's/[^/]*$//')"/..
if test -d .git/.git; then
die "The directory '.git/.git' exists, indicating a configuration error.
Please 'rm -rf' this directory."
fi
echo "Configuring push urls..."
git config remote.origin.pushurl git@vtk.org:VTK.git
cd "${BASH_SOURCE%/*}/.." &&
Utilities/Scripts/SetupUser.sh && echo &&
Utilities/Scripts/SetupHooks.sh && echo &&
Utilities/Scripts/SetupGitAliases.sh && echo &&
(Utilities/Scripts/SetupGerrit.sh ||
echo 'Failed to setup Gerrit. Run this again to retry.') && echo &&
Utilities/Scripts/GitTips.sh
# Rebase master by default
git config rebase.stat true
git config branch.master.rebase true
cd Utilities/Scripts
echo "Checking basic user information..."
./SetupUser.sh || exit 1
echo
echo "Setting up git hooks..."
./SetupHooks.sh || exit 1
echo
echo "Setting up the topic stage..."
./SetupTopicStage.sh || exit 1
echo
echo "Setting up git aliases..."
./SetupGitAliases.sh || exit 1
echo
echo "Setting up Gerrit..."
./SetupGerrit.sh || exit 1
echo
echo "Suggesting git tips..."
./GitTips.sh || exit 1
echo
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment