-
Notifications
You must be signed in to change notification settings - Fork 4
/
git-pz
executable file
·29 lines (26 loc) · 986 Bytes
/
git-pz
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
#
# Helper script to push to own github fork repo and to open a request
# using "hub" helper tool.
#
REMOTE=$USER
BRANCH=`git symbolic-ref -q HEAD | sed "s|refs/heads/||"`
echo "Pushing the following commits to $REMOTE/$BRANCH"
git --no-pager log HEAD^! --abbrev-commit --pretty=oneline
if ! git push --set-upstream $REMOTE $BRANCH; then
# remote branch already exists - try to force push
echo "Push failed, try again with --force?"
read && git push --set-upstream $REMOTE $BRANCH --force
else
# remote branch was new - offer creating a pull-request
git branch
read -p "Open PR (d - develop; m = master; g = gh-pages; r = rpm/develop; u = deb/develop)?" response
case $response in
[Mm]* ) hub pull-request $*;;
[Rr]* ) hub pull-request -b rpm/develop $*;;
[Uu]* ) hub pull-request -b deb/develop $*;;
[Dd]* ) hub pull-request -b develop $*;;
[Gg]* ) hub pull-request -b gh-pages $*;;
* ) echo "Not creating pull-request";;
esac
fi