Skip to content

Instantly share code, notes, and snippets.

@rafaelqueiroz88
Created November 12, 2022 02:18
Show Gist options
  • Save rafaelqueiroz88/b00197e556cbd54b00c4a9ce70ad4de6 to your computer and use it in GitHub Desktop.
Save rafaelqueiroz88/b00197e556cbd54b00c4a9ce70ad4de6 to your computer and use it in GitHub Desktop.
Creating a Post-Checkout Hook
#!/bin/bash
# File checkout
if [ "$3" == "0" ]; then exit; fi
NUM_CHECKOUTS=`git reflog --date=local | grep -o ${BRANCH_NAME} | wc -l`
# If the refs of the previous and new heads are the same
# AND the number of checkouts equals one, a new branch has been created
if [ "$1" == "$2" ] && [ ${NUM_CHECKOUTS} -eq 1 ]; then
.github/run-rubocop.bash
.github/run-rspec.bash
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment