Skip to content

Instantly share code, notes, and snippets.

@turtlebender
Created September 10, 2012 20:23
Show Gist options
  • Save turtlebender/3693590 to your computer and use it in GitHub Desktop.
Save turtlebender/3693590 to your computer and use it in GitHub Desktop.
Installs Snakegit
#!/usr/bin/env bash
# Welcome message
cat <<EOM
____ _ ____ _ _
/ ___| _ __ __ _| | _____ / ___(_) |_
\___ \| '_ \ / _' | |/ / _ \ | _| | __|
___) | | | | (_| | < __/ |_| | | |_
|____/|_| |_|\__,_|_|\_\___|\____|_|\__|
EOM
echo "This installer configures your development environment"
echo "to work with the SnakeGit set of tools. SnakeGit "
echo "integrates standard development and build workflows "
echo "with git for a (hopefully) more consistent development"
echo "experience."
echo ""
echo "Would you like to continue with installing [y] ?"
read INSTALL
if [ "$INSTALL" == "n" ] || [ "$INSTALL" == "N" ]
then
echo "Sorry to hear it"
exit
fi
# getopt on OS X is inherently broken. We might end up with unexpected
# behavior if it is used. This will give people the chance to install
# homebrew and then install a good getopt. This also affects gitflow
unamestr=`uname`
function configure_os_x {
which brew
if [[ $? -ne 0 ]]
then
echo "Some bash features do not work nicely with OS X"
echo "To fix this, we can install Homebrew (http://mxcl.github.com/homebrew)"
echo "Homebrew is a package manager similar to apt-get or yum"
echo "It can make lots of tasks a lot easier, in addition to"
echo "fixing the issues here."
echo ""
echo "Would you like to install brew now (recommended) [y] ?"
read INSTALL_BREW
if [ "$INSTALL_BREW" == "Y" ] || [ "$INSTALL_BREW" == "y" ] || [ "$INSTALL_BREW" == "" ]
then
ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go)
brew install gnu-getopt
echo 'export FLAGS_GETOPT_CMD="$(brew --prefix gnu-getopt)/bin/getopt"' >> ~/.bashrc
echo "To make sure that you pick up the changes made here"
echo "Please reload your ~/.bashrc file:"
echo ". ~/.bashrc"
fi
fi
}
if [[ "$unamestr" == 'darwin' ]]
then
configure_os_x
fi
#Now that that is taken care of, install snakegit
test -v SNAKEGIT_HOME || SNAKEGIT_HOME=${HOME}/.snakegit
echo "Where do you want to install SnakeGit [$SNAKEGIT_HOME] ?"
read LOCATION
if [ "$LOCATION" != "" ]
then
SNAKEGIT_HOME=$LOCATION
fi
echo "Configuring SnakeGit home in ${HOME}/.bashrc"
echo ""
grep SNAKEGIT_HOME ~/.bashrc
test $? -eq 0 || echo "export SNAKEGIT_HOME=$SNAKEGIT_HOME" >> ${HOME}/.bashrc
if [ -d $SNAKEGIT_HOME ]
then
cd $SNAKEGIT_HOME
echo "Updating your SnakeGit install"
echo ""
git pull origin master >> $SNAKEGIT_HOME/install.log 2>&1
git submodule update >> $SNAKEGIT_HOME/install.log 2>&1
else
echo "Installing SnakeGit"
echo ""
git clone https://github.com/NarrativeScience/snakegit.git $SNAKEGIT_HOME >> $SNAKEGIT_HOME/install.log 2>&1
cd $SNAKEGIT_HOME
git submodule init >> $SNAKEGIT_HOME/install.log 2>&1
git submodule update >> $SNAKEGIT_HOME/install.log 2>&1
fi
# Configure PyPi username
current_username=`git config --global --get pypi.user`
echo "Please enter your PyPi username: [$current_username]"
read USERNAME
if [ -v current_username ]
then
if [ ! "$USERNAME" == '' ] && [ "$USERNAME" != "$current_username" ]
then
git config --global --unset pypi.user
git config --global --add pypi.user $USERNAME
fi
fi
# Install git aliases
echo "Now installing git aliases"
echo ""
git config --get alias.build > /dev/null
if [ $? -ne 0 ]
then
git config --global --add alias.build "! /usr/bin/env bash $SNAKEGIT_HOME/bin/build.sh"
fi
git config --get alias.upload-package > /dev/null
if [ $? -ne 0 ]
then
git config --global --add alias.upload-package "! /usr/bin/env bash $SNAKEGIT_HOME/bin/upload.sh"
fi
git config --get alias.test > /dev/null
if [ $? -ne 0 ]
then
git config --global --add alias.test "! /usr/bin/env bash $SNAKEGIT_HOME/bin/test.sh"
fi
git config --get alias.lint > /dev/null
if [ $? -ne 0 ]
then
git config --global --add alias.lint "! /usr/bin/env bash $SNAKEGIT_HOME/bin/lint.sh"
fi
git config --get alias.sdist > /dev/null
if [ $? -ne 0 ]
then
git config --global --add alias.sdist "! /usr/bin/env bash $SNAKEGIT_HOME/bin/sdist.sh"
fi
git config --get alias.dev-clean > /dev/null
if [ $? -ne 0 ]
then
git config --global --add alias.dev-clean "! /usr/bin/env bash $SNAKEGIT_HOME/bin/clean.sh"
fi
git config --get alias.selfupdate > /dev/null
if [ $? -ne 0 ]
then
git config --global --add alias.selfupdate "! /usr/bin/env bash $SNAKEGIT_HOME/bin/selfupdate"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment