1 |
ron |
1 |
#!/usr/bin/env bash
|
|
|
2 |
#
|
|
|
3 |
# mfpr
|
|
|
4 |
#
|
|
|
5 |
# Make a PR of the current branch against RCBugFix or dev
|
|
|
6 |
#
|
|
|
7 |
|
|
|
8 |
[[ $# < 2 && $1 != "-h" && $1 != "--help" ]] || { echo "Usage: `basename $0` [branch]" 1>&2 ; exit 1; }
|
|
|
9 |
|
|
|
10 |
MFINFO=$(mfinfo "$@") || exit 1
|
|
|
11 |
IFS=' ' read -a INFO <<< "$MFINFO"
|
|
|
12 |
ORG=${INFO[0]}
|
|
|
13 |
FORK=${INFO[1]}
|
|
|
14 |
REPO=${INFO[2]}
|
|
|
15 |
TARG=${INFO[3]}
|
|
|
16 |
BRANCH=${INFO[4]}
|
|
|
17 |
OLDBRANCH=${INFO[5]}
|
|
|
18 |
|
|
|
19 |
[[ $BRANCH == $TARG ]] && { echo "Can't create a PR from the PR Target ($BRANCH). Make a copy first." 1>&2 ; exit 1; }
|
|
|
20 |
|
|
|
21 |
[[ $BRANCH != $OLDBRANCH ]] && { git checkout $BRANCH || exit 1; }
|
|
|
22 |
|
|
|
23 |
# See if it's been pushed yet
|
|
|
24 |
if [ -z "$(git branch -vv | grep ^\* | grep \\[origin)" ]; then firstpush; fi
|
|
|
25 |
|
|
|
26 |
TOOL=$(which gnome-open xdg-open open | awk '{ print $1 }')
|
|
|
27 |
URL="https://github.com/$ORG/$REPO/compare/$TARG...$FORK:$BRANCH?expand=1"
|
|
|
28 |
|
|
|
29 |
if [ -z "$TOOL" ]; then
|
|
|
30 |
echo "Can't find a tool to open the URL:"
|
|
|
31 |
echo $URL
|
|
|
32 |
else
|
|
|
33 |
echo "Opening a New PR Form..."
|
|
|
34 |
"$TOOL" "$URL"
|
|
|
35 |
fi
|
|
|
36 |
|
|
|
37 |
[[ $BRANCH != $OLDBRANCH ]] && git checkout $OLDBRANCH
|