File tree 3 files changed +30
-0
lines changed
3 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -226,6 +226,7 @@ And here are the operations that will need to write to your git repository.
226
226
227
227
g.fetch
228
228
g.fetch(g.remotes.first)
229
+ g.fetch(' origin' , {:ref => ' some/ref/head' } )
229
230
230
231
g.pull
231
232
g.pull(Git ::Repo , Git ::Branch ) # fetch and a merge
Original file line number Diff line number Diff line change @@ -738,6 +738,7 @@ def tag(name, *opts)
738
738
739
739
def fetch ( remote , opts )
740
740
arr_opts = [ remote ]
741
+ arr_opts << opts [ :ref ] if opts [ :ref ]
741
742
arr_opts << '--tags' if opts [ :t ] || opts [ :tags ]
742
743
arr_opts << '--prune' if opts [ :p ] || opts [ :prune ]
743
744
Original file line number Diff line number Diff line change @@ -122,6 +122,34 @@ def test_fetch
122
122
assert ( loc . tags . map ( &:name ) . include? ( 'test-tag-in-deleted-branch' ) )
123
123
end
124
124
end
125
+
126
+ def test_fetch_ref_adds_ref_option
127
+ in_temp_dir do |path |
128
+ loc = Git . clone ( @wbare , 'local' )
129
+ rem = Git . clone ( @wbare , 'remote' , :config => 'receive.denyCurrentBranch=ignore' )
130
+ loc . add_remote ( 'testrem' , rem )
131
+
132
+ loc . chdir do
133
+ new_file ( 'test-file1' , 'gonnaCommitYou' )
134
+ loc . add
135
+ loc . commit ( 'master commit 1' )
136
+ first_commit_sha = loc . log . first . sha
137
+
138
+ new_file ( 'test-file2' , 'gonnaCommitYouToo' )
139
+ loc . add
140
+ loc . commit ( 'master commit 2' )
141
+ second_commit_sha = loc . log . first . sha
142
+
143
+ # Make sure fetch message only has the first commit when we fetch the first commit
144
+ assert ( loc . fetch ( 'origin' , { :ref => first_commit_sha } ) . include? ( first_commit_sha ) )
145
+ assert ( !loc . fetch ( 'origin' , { :ref => first_commit_sha } ) . include? ( second_commit_sha ) )
146
+
147
+ # Make sure fetch message only has the second commit when we fetch the second commit
148
+ assert ( loc . fetch ( 'origin' , { :ref => second_commit_sha } ) . include? ( second_commit_sha ) )
149
+ assert ( !loc . fetch ( 'origin' , { :ref => second_commit_sha } ) . include? ( first_commit_sha ) )
150
+ end
151
+ end
152
+ end
125
153
126
154
def test_push
127
155
in_temp_dir do |path |
You can’t perform that action at this time.
0 commit comments