-
-
Save colindensem/229256 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Runs `git push` before `cap deploy` | |
# Otherwise just passes through to `cap` | |
function cap { | |
CAP="`which cap`" | |
if [[ "$1" == "deploy" || "$2" == "deploy" ]]; then | |
git push && $CAP $* | |
else | |
$CAP $* | |
fi | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## My magical git function ## | |
# Adds various checks to `git` as detailed below: | |
# * Makes sure you've run your specs/features before pushing | |
# * Asks for confirmation before committing on master | |
function git { | |
GIT="`which git`" | |
CONTINUE=true | |
# git push | |
# Checks if there are spec/ or features/ folders and | |
# questions the user if they have been run if they exist. | |
if [[ "$1" == "push" ]]; then | |
# Check if spec/ exists | |
if [[ -e spec ]]; then | |
CONTINUE=false # fail by default | |
# Ask the user | |
echo -n "Have you run your specs? [Y/n]" | |
read a | |
if [[ $a == "Y" || $a == "y" || $a == "" ]]; then | |
CONTINUE=true | |
fi | |
fi | |
# Check if features/ exists | |
if [[ -e features ]]; then | |
CONTINUE=false # fail by default | |
# Ask the user | |
echo -n "Have you run your features? [Y/n]" | |
read a | |
if [[ $a == "Y" || $a == "y" || $a == "" ]]; then | |
CONTINUE=true | |
fi | |
fi | |
# git commit | |
# Checks if we're on the master branch and | |
# double-checks with the user if they are | |
elif [[ "$1" == "commit" || "$1" == "vi" || "$1" == "via" || "$1" == "viaa" ]]; then | |
# Check the branch we're on | |
if [[ `parse_git_branch` == "(master)" ]]; then | |
CONTINUE=false # fail by default on master | |
# We're on master! Make sure we want to commit here | |
echo "= WARNING: Committing on master =" | |
echo -n "Continue? [y/N]" | |
read a | |
if [[ $a == "y" || $a == "Y" || $a == "yes" ]]; then | |
# They must really want to commit on master | |
CONTINUE=true | |
else | |
echo "Not committing." | |
fi | |
fi | |
fi | |
# Run the command if we've been told to. | |
# The default is to run the command so this only | |
# fires if a check has disabled it. | |
if [[ $CONTINUE == true ]]; then | |
$GIT $* | |
fi | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ss # => ./script/server | |
# ss 3001 # => ./script/server -p 3001 | |
# ss test # => ./script/server -e test | |
# ss test 3001 # => ./script/server -e test -p 3001 | |
function ss { | |
if [[ -z "$1" ]]; then | |
ruby script/server | |
elif [[ -z "$2" ]]; then | |
# Is it a port or an env? | |
if [[ "$1" =~ [0-9]+ ]]; then | |
# Its a port | |
ruby script/server -p $1 | |
else # its an env name | |
ruby script/server -e $1 | |
fi | |
else | |
ruby script/server -e $1 -p $2 | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment