This repository was archived by the owner on Nov 8, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +41
-0
lines changed Expand file tree Collapse file tree 3 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -114,6 +114,17 @@ git config --get pullrequest.id # returns the ID number of the PR
114
114
git config --get pullrequest.basebranch # returns the base branch used for the pull request
115
115
` ` `
116
116
117
+
118
+ # ### Additional files populated
119
+
120
+ * `.git/id`: the pull request id
121
+
122
+ * `.git/url`: the URL for the pull request
123
+
124
+ * `.git/branch`: the branch associated with the pull request
125
+
126
+ * `.git/base_branch`: the base branch of the pull request
127
+
117
128
# ### Parameters
118
129
119
130
* `git.depth`: *Optional.* If a positive integer is given, *shallow* clone the
Original file line number Diff line number Diff line change @@ -24,6 +24,15 @@ def output
24
24
25
25
raise 'git clone failed' unless $CHILD_STATUS. exitstatus . zero?
26
26
27
+ Dir . chdir ( File . join ( destination , '.git' ) ) do
28
+ system <<-BASH
29
+ echo "#{ pr [ 'html_url' ] } " > url
30
+ echo "#{ pr [ 'number' ] } " > id
31
+ echo "#{ pr [ 'head' ] [ 'ref' ] } " > branch
32
+ echo "#{ pr [ 'base' ] [ 'ref' ] } " > base_branch
33
+ BASH
34
+ end
35
+
27
36
Dir . chdir ( destination ) do
28
37
raise 'git clone failed' unless system ( "git fetch -q origin pull/#{ id } /#{ remote_ref } :#{ branch_ref } 1>&2" )
29
38
Original file line number Diff line number Diff line change @@ -87,6 +87,27 @@ def dest_dir
87
87
value = git ( 'config pullrequest.basebranch' , dest_dir )
88
88
expect ( value ) . to eq 'master'
89
89
end
90
+
91
+ it 'creates a file that icludes the id in the .git folder' do
92
+ value = File . read ( File . join ( dest_dir , '.git' , 'id' ) ) . strip ( )
93
+ expect ( value ) . to eq '1'
94
+ end
95
+
96
+ it 'creates a file that icludes the url in the .git folder' do
97
+ value = File . read ( File . join ( dest_dir , '.git' , 'url' ) ) . strip ( )
98
+ expect ( value ) . to eq 'http://example.com'
99
+ end
100
+
101
+ it 'creates a file that icludes ahe branch in the .git folder' do
102
+ value = File . read ( File . join ( dest_dir , '.git' , 'branch' ) ) . strip ( )
103
+ expect ( value ) . to eq 'foo'
104
+ end
105
+
106
+ it 'creates a file that icludes the base_branch in the .git folder' do
107
+ value = File . read ( File . join ( dest_dir , '.git' , 'base_branch' ) ) . strip ( )
108
+ expect ( value ) . to eq 'master'
109
+ end
110
+
90
111
end
91
112
92
113
context 'when the git clone fails' do
You can’t perform that action at this time.
0 commit comments