add new git commands: open-in-github and push-feature-branch

This commit is contained in:
Sami Samhuri 2015-08-17 15:16:20 -07:00
parent 84c2be499f
commit d1126138f7
2 changed files with 23 additions and 0 deletions

10
git-open-in-github Executable file
View file

@ -0,0 +1,10 @@
#!/bin/sh
REMOTE="${1:-origin}"
BRANCH="${2:-$(git rev-parse --abbrev-ref HEAD)}"
REPO=$(git config --get remote.${REMOTE}.url | cut -d':' -f2 | cut -d'.' -f1)
if [[ -z "$REPO" ]] || [[ -z "$BRANCH" ]]; then
echo "usage: $(basename "$0") <remote> <branch (ref)>"
exit 1
fi
open "https://github.com/${REPO}/compare/${BRANCH}?expand=1"

13
git-push-feature-branch Executable file
View file

@ -0,0 +1,13 @@
#!/bin/sh
set -e # bail on errors
REMOTE="${1:-origin}"
BRANCH="${2:-$(git rev-parse --abbrev-ref HEAD)}"
git update "$REMOTE" develop
git checkout develop
git merge --no-ff "$BRANCH"
git push
git checkout "$BRANCH"
git push -u "$REMOTE" "$BRANCH"