Skip to content

Instantly share code, notes, and snippets.

@mycargus
Last active August 29, 2015 14:25
Show Gist options
  • Select an option

  • Save mycargus/64b3186ded5c5006368d to your computer and use it in GitHub Desktop.

Select an option

Save mycargus/64b3186ded5c5006368d to your computer and use it in GitHub Desktop.
I got tired of repeating myself and forgetting commands when creating a new branch for automating specs.
#!/bin/bash
# Add me to your .bashrc file (except for the shebang at the top of this file)
# Usage: `create_new_specs_branch <name_of_new_branch>`
# Example: `create_new_specs_branch quiz_spec`
create_new_specs_branch() {
cd ~/code/canvas-lms-local # <--- change this path according to your setup
printf "\nI moved you into $(pwd). You're welcome.\n"
printf "\nStashing any changes... (I gotch yo back)\n"
git stash
printf "\ngit fetchin' master...\n"
git fetch
printf "\nNow to rebase all your things...\n"
git rebase
RAILS_ENV=development # set me to test, production, or development
printf "\nI set your RAILS_ENV to \"$(echo $RAILS_ENV)\". Makin' it happen.\n"
printf "\nInstalling gems...\n"
bundle install
printf "\nStarting up postgres db..."
postgres -D /var/lib/postgres/data
printf "\nStarting up selenium server..."
java -jar ~/Downloads/selenium-server-standalone-2.46.0.jar
printf "\nMigrating any db changes...\n"
bundle exec rake db:migrate
printf "\nCreating new branch: $(echo $1)\n"
git checkout -b $1
# Uncomment the following three lines if you want to compile assets
# printf "\nCompiling assets..."
# printf "\n(Now's a good time to take a nap)\n"
# bundle exec rake canvas:compile_assets[true]
# Note: This ^ command may need to be altered soon due to pending gulp changes
printf "\nSetting branch upstream to master...\n"
git branch --set-upstream-to=origin/master
printf "\n\"Yesterday, you said tomorrow. JUST DO IT!!!\"\n" # - Shia LaBeouf https://www.youtube.com/watch?v=nuHfVn_cfHU
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment