-
Notifications
You must be signed in to change notification settings - Fork 0
/
prit
executable file
·33 lines (30 loc) · 889 Bytes
/
prit
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
29
30
31
32
33
#!/bin/bash
# Taken from my own bash config, just dumped here
# Helper to send a PR, just specify which remote to send through,
# If None specified - will use the one as gh-$(git config github.user).
set -eu
ghsendpr () {
r="${1:-}"
if [ -z "$r" ]; then
r="gh-$(git config github.user)"
fi
br=$(git branch --no-color | awk '/^\*/{print $2;}')
if [ "$br" = 'master' ]
then
echo "You are on the master branch. Which branch should I push to?"
read -r brpr
echo "Ok -- will push to $br"
else
brpr="$br"
fi
if [ "$br" != "" ]
then
git push -u "$r" "$br:$brpr"
rpushurl=$(git remote show -n "$r" | awk '/^ *Push URL/{print $3;}')
lr=$(echo "$rpushurl" | sed -e 's,.*github.com[:/]\(.*\)/\(.*\),\1/\2,' | sed -e 's/\.git$//g')
newprurl="http://github.com/${lr}/pull/new/$brpr"
echo "opening browser for $newprurl"
x-www-browser "$newprurl"
fi
}
ghsendpr "$@"