Sun, 06 Jul 2014 20:46:36 +0300
- added various safeguards to pullreq
0
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | #!/bin/bash |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | hg log -r tip >/dev/null || exit 1 |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
3 | |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | if [ -z "$(which curl)" ] |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | then |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | echo "no curl installed" >/dev/stderr |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | exit 1 |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | fi |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | |
3
b328fdc09692
- add commentary to pull-request.sh, added missing template JSON, fixed copyright year in LICENSE
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
10 | # Get path to this script |
4
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
3
diff
changeset
|
11 | pushd $(dirname $0) >/dev/null |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
3
diff
changeset
|
12 | selfpath=$(dirname $(readlink $0)) |
3
b328fdc09692
- add commentary to pull-request.sh, added missing template JSON, fixed copyright year in LICENSE
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
13 | popd >/dev/null |
b328fdc09692
- add commentary to pull-request.sh, added missing template JSON, fixed copyright year in LICENSE
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
14 | |
b328fdc09692
- add commentary to pull-request.sh, added missing template JSON, fixed copyright year in LICENSE
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
15 | # What's the upstream? |
b328fdc09692
- add commentary to pull-request.sh, added missing template JSON, fixed copyright year in LICENSE
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
16 | # TODO: can this be dynamically retrieved from bitbucket? |
0
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | upstream=$(hg paths upstream |rev |cut -d '/' -f 1,2 |rev) |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | if [ -z "$upstream" ] |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | then |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | echo "cannot find upstream! Please set the 'upstream' path in .hg/hgrc" >/dev/stderr |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | exit 1 |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | fi |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | echo "upstream is $upstream" |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | |
3
b328fdc09692
- add commentary to pull-request.sh, added missing template JSON, fixed copyright year in LICENSE
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
27 | # Get all heads and filter merges out since we don't generally want to post |
b328fdc09692
- add commentary to pull-request.sh, added missing template JSON, fixed copyright year in LICENSE
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
28 | # pull requests for those. |
9
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
29 | # allheads=$(hg heads --template '{node}@{parents}\n' |sed 's@ @#@g') |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
30 | heads=$(hg heads --template '{node}\n') |
0
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | i=0 |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | |
9
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
33 | #for head in $allheads |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
34 | #do |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
35 | # if [ "$(echo $head |sed 's@#@ @g' |wc -w)" -le "1" ] |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
36 | # then |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
37 | # heads="${heads}$(echo $head |cut -f 1 -d '@') " |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
38 | # fi |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
39 | #done |
0
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
40 | |
9
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
41 | #if [ -z "$allheads" ] |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
42 | #then |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
43 | # echo "No non-merge heads. Nothing to do." |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
44 | # exit 0 |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
45 | #fi |
3
b328fdc09692
- add commentary to pull-request.sh, added missing template JSON, fixed copyright year in LICENSE
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
46 | |
0
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
47 | numheads=$(echo $heads |wc -w) |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
48 | |
3
b328fdc09692
- add commentary to pull-request.sh, added missing template JSON, fixed copyright year in LICENSE
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
49 | # Ask the user which head to request pull of. We do this even if there is just |
b328fdc09692
- add commentary to pull-request.sh, added missing template JSON, fixed copyright year in LICENSE
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
50 | # one head, to give the user a chance to review exactly what is being submitted. |
9
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
51 | echo "There are $numheads heads:" |
0
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
52 | |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
53 | for head in $heads |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | do |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | let i+=1 |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | bookmarksblurb="" |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | tmpfile=$(tempfile) |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
58 | hg log -r $head --template '{bookmarks}\n{desc}\n' >$tmpfile |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
59 | bookmarks=$(head -n1 $tmpfile) |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
60 | title=$(tail -n1 $tmpfile) |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
61 | rm $tmpfile |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
62 | |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
63 | if [ -n "$bookmarks" ] |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
64 | then |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
65 | bookmarksblurb=" [${bookmarks}]" |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
66 | fi |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
67 | |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
68 | echo "[${i}] $(echo $head |head -c 8)${bookmarksblurb}: $title" |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
69 | done |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
70 | |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
71 | head_index=-1 |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
72 | while [ "$head_index" -le "0" -o "$head_index" -gt "$numheads" ] |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
73 | do |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
74 | echo -n "Which head? " |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
75 | read head_index |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
76 | done |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
77 | |
3
b328fdc09692
- add commentary to pull-request.sh, added missing template JSON, fixed copyright year in LICENSE
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
78 | # Data for the pull request |
0
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
79 | head=$(echo $heads |cut -d ' ' -f $head_index) |
3
b328fdc09692
- add commentary to pull-request.sh, added missing template JSON, fixed copyright year in LICENSE
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
80 | title=$(hg log -r ${head} -r tip --template '{desc}') |
0
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
81 | source_repo=$(hg paths default |rev |cut -d '/' -f 1,2 |rev) |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
82 | |
9
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
83 | titlefile=$(tempfile) |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
84 | echo "$title" >$titlefile |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
85 | vim $titlefile |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
86 | title=$(cat $titlefile) |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
87 | |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
88 | if [ -z "$title" ] |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
89 | then |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
90 | echo "no title given" |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
91 | exit 1 |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
92 | fi |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
93 | |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
94 | # Ensure history is compressed.. |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
95 | upstream_tip=$(hg log -r upstream_tip --template '{node}\n') |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
96 | parents=$(hg log -r $head --debug --template '{parents}\n') |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
97 | p1=$(hg log -r $(echo $parents |cut -f 1 -d ' ') --template '{node}\n') |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
98 | p2=$(hg log -r $(echo $parents |cut -f 2 -d ' ') --template '{node}\n') |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
99 | |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
100 | if [ "$p1" != "$upstream_tip" -a "$p2" != "$upstream_tip" ] |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
101 | then |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
102 | echo -n "history isn't compressed! compress now? [y/n] " |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
103 | read answer |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
104 | if [ "$answer" = "y" ] |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
105 | then |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
106 | bookmarks=$(hg log -r $head --template '{bookmarks}') |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
107 | oldhead=$head |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
108 | hg up -r upstream_tip && |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
109 | hg revert --all -r $head && |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
110 | hg commit -m "$title" || exit 1 |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
111 | head=$(hg id -i) |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
112 | hg bookmarks -f $bookmarks |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
113 | hg up -r $oldhead && hg commit -m "- closed head $oldhead" --close-branch && hg up -r $head |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
114 | fi |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
115 | fi |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
116 | |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
117 | # Ensure the head is pushed! |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
118 | if [ -n $( hg outgoing --template '{node}\n' 2>/dev/null |grep $head ) ] |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
119 | then |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
120 | echo -en "$head is not pushed!\npush now? [y/n] " |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
121 | read answer |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
122 | if [ "$answer" != "y" ] |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
123 | then |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
124 | echo "abort: head is not pushed" |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
125 | exit 1 |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
126 | fi |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
127 | |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
128 | hg push -r $head -f |
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
129 | fi |
0
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
130 | |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
131 | echo "Requesting pull of $head" |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
132 | |
3
b328fdc09692
- add commentary to pull-request.sh, added missing template JSON, fixed copyright year in LICENSE
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
133 | # Get the JSON template and fill in the values |
b328fdc09692
- add commentary to pull-request.sh, added missing template JSON, fixed copyright year in LICENSE
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
134 | json=$(cat $selfpath/pullrequest_template.json \ |
0
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
135 | |sed "s@{{TITLE}}@${title}@" \ |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
136 | |sed "s@{{SOURCE_REPO}}@${source_repo}@" \ |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
137 | |sed "s@{{HEAD}}@${head}@") |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
138 | |
3
b328fdc09692
- add commentary to pull-request.sh, added missing template JSON, fixed copyright year in LICENSE
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
139 | # Get bitbucket credentials |
9
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
140 | echo -n "username: " |
0
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
141 | read username |
9
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
142 | echo -n "password: " |
0
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
143 | read -s password |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
144 | echo |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
145 | |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
146 | response=$(tempfile) |
9a7158f91b97
- initial commit (added pull-request.sh)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
147 | |
3
b328fdc09692
- add commentary to pull-request.sh, added missing template JSON, fixed copyright year in LICENSE
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
148 | # Post the pull request. |
4
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
3
diff
changeset
|
149 | curl \ |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
3
diff
changeset
|
150 | -X POST \ |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
3
diff
changeset
|
151 | -H "Content-Type: application/json" \ |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
3
diff
changeset
|
152 | -u "${username}:${password}" \ |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
3
diff
changeset
|
153 | -d "$json" \ |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
3
diff
changeset
|
154 | -o "$response" \ |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
3
diff
changeset
|
155 | "https://api.bitbucket.org/2.0/repositories/${upstream}/pullrequests" \ |
9
7e8ccf76a84d
- added various safeguards to pullreq
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
156 | >/dev/stdout 2>&1 |