Skip to content

Instantly share code, notes, and snippets.

@passcod
Last active December 12, 2015 09:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save passcod/4752466 to your computer and use it in GitHub Desktop.
Save passcod/4752466 to your computer and use it in GitHub Desktop.
Script to automate merging PRs on [homebrew-cask](https://github.com/phinze/homebrew-cask)
#!/bin/bash
if [[ -z "$1" ]]; then
echo " => Usage: $0 user:branch"
exit 64
fi
user=$(cut -d ":" -f1 <(echo "$1"))
repo="homebrew-cask"
branch=$(cut -d ":" -f2 <(echo "$1"))
if ls | grep -q brew-cask.rb; then
echo -n " => Switch to master… "
if git checkout master; then
echo "OK"
else
echo " => Git error"
exit 69
fi
else
echo " => We’re not at root of $repo"
exit 64
fi
echo " => Fetch $1"
git fetch "git://github.com/$user/$repo" "$branch"
sha=$(git rev-parse --verify FETCH_HEAD)
echo " => SHA: $sha"
echo " => Cherry-pick commit to master"
git cherry-pick "$sha"
echo "git commit --amend --signoff" | pbcopy
echo " => You can now look around and finish the merge"
echo " => Use: git commit --amend --signoff (just ⌘ + V)"
echo " => "
echo " => Format for commit message is usually:"
echo " => "
echo " => Software Name 1.2.3"
echo " => "
echo " => Closes #123."
echo " => "
echo " => Signed-off by: John Doe <john@doe.com>"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment