forked from 8percent/github-flow-sugar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit-pr
executable file
·50 lines (41 loc) · 869 Bytes
/
git-pr
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
if [ $# -ne 0 ]
then
echo "usage: $(basename $0)"
exit 1
fi
BR_MASTER="master"
CURRENT=$(git rev-parse --abbrev-ref HEAD)
STATUS=$(git branch -vv)
# push를 해봅시다
# tracking이 되는지 확인
if [[ $STATUS == *origin/$CURRENT* ]]
then
# 이미 push가 되었는지 확인
if [ $(git rev-parse $CURRENT) != $(git rev-parse origin/$CURRENT) ]
then
git push origin $CURRENT
fi
else
git push -u origin $CURRENT
fi
if [ $? -ne 0 ]
then
echo "Push failed"
exit 1
fi
# Compare url 만들고 브라우저로 열기
GITHUB_ID=$(git config --get remote.origin.url | sed -e 's/^[^:]*://' | sed -e 's/.git$//')
URL="https://github.com/$GITHUB_ID/compare/$BR_MASTER...$CURRENT"
case $(uname -s) in
"Darwin")
open $URL
;;
"Linux")
xdg-open $URL
;;
*)
echo "Access link to compare and create pull request"
echo $URL
;;
esac