Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/bash
#
# Uses github's hub command line tool and r10kdiff gem to open a pull request
# for a repository containing a Puppetfile used by r10k.
#
# Assumes it should be from the current branch <Puppet Environment Name> in a
# fork to the same branch upstream (since you can't use feature branches in the
# same repository with r10k as it might deploy them as environments)
#
if [ $# -ne 2 ] ;
then
echo "Usage: open-r10k-repo-pull-request <github-user> <upstream-user-or-org>"
exit 1
else
github_username=$1
upstream_github_username=$2
fi
# Make sure we're in a git repo
git status >/dev/null 2>&1 || ( echo "ERROR: Need to run from a git repo" && exit 1 )
branchname="$(basename $(git symbolic-ref HEAD))"
tmpfile="./puppet-environments-pr-tmp.txt"
# PR name defaults to last commit msg like when opening from the web UI
echo -e "$(git log $branchname -n 1 --pretty=format:%s)\n\n" > $tmpfile
r10kdiff --urls origin/$branchname $branchname >> $tmpfile
"${EDITOR:-vi}" $tmpfile
hub pull-request -F $tmpfile -b $upstream_github_username:$branchname -h $github_username:$branchname
rm $tmpfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.