@@ -26,6 +26,7 @@ def commit(msg)
26
26
commit ( 'second' )
27
27
28
28
git ( "update-ref refs/pull/1/head #{ @ref } " )
29
+ git ( "update-ref refs/pull/1/merge #{ @ref } " )
29
30
end
30
31
31
32
context 'for every PR that is checked out' do
@@ -55,11 +56,11 @@ def commit(msg)
55
56
expect ( value ) . to eq 'http://example.com'
56
57
end
57
58
58
- it 'checks out as a branch' do
59
+ it 'checks out as a branch with a `pr-` prefix ' do
59
60
get ( version : { ref : @ref , pr : '1' } , source : { uri : git_uri , repo : 'jtarchie/test' } )
60
61
61
62
value = git ( 'rev-parse --abbrev-ref HEAD' , dest_dir )
62
- expect ( value ) . to eq 'foo'
63
+ expect ( value ) . to eq 'pr- foo'
63
64
end
64
65
65
66
it 'sets config variable to branch name' do
@@ -92,7 +93,15 @@ def commit(msg)
92
93
get ( version : { ref : @ref , pr : '1' } , source : { uri : git_uri , repo : 'jtarchie/test' } , params : { fetch_merge : false } )
93
94
94
95
value = git ( 'rev-parse --abbrev-ref HEAD' , dest_dir )
95
- expect ( value ) . to eq 'foo'
96
+ expect ( value ) . to eq 'pr-foo'
97
+ end
98
+
99
+ it 'does not fail cloning' do
100
+ proxy . stub ( 'https://api.github.com:443/repos/jtarchie/test/pulls/1' )
101
+ . and_return ( json : { html_url : 'http://example.com' , number : 1 , head : { ref : 'foo' } , mergeable : true } )
102
+
103
+ _ , error = get ( version : { ref : @ref , pr : '1' } , source : { uri : git_uri , repo : 'jtarchie/test' } , params : { fetch_merge : false } )
104
+ expect ( error ) . not_to include 'git clone failed'
96
105
end
97
106
end
98
107
@@ -104,7 +113,15 @@ def commit(msg)
104
113
get ( version : { ref : @ref , pr : '1' } , source : { uri : git_uri , repo : 'jtarchie/test' } , params : { fetch_merge : true } )
105
114
106
115
value = git ( 'rev-parse --abbrev-ref HEAD' , dest_dir )
107
- expect ( value ) . to eq 'master'
116
+ expect ( value ) . to eq 'pr-foo'
117
+ end
118
+
119
+ it 'does not fail cloning' do
120
+ proxy . stub ( 'https://api.github.com:443/repos/jtarchie/test/pulls/1' )
121
+ . and_return ( json : { html_url : 'http://example.com' , number : 1 , head : { ref : 'foo' } , mergeable : true } )
122
+
123
+ _ , error = get ( version : { ref : @ref , pr : '1' } , source : { uri : git_uri , repo : 'jtarchie/test' } , params : { fetch_merge : true } )
124
+ expect ( error ) . not_to include 'git clone failed'
108
125
end
109
126
end
110
127
end
0 commit comments