File tree 4 files changed +36
-6
lines changed 4 files changed +36
-6
lines changed Original file line number Diff line number Diff line change @@ -332,8 +332,8 @@ def checkout_file(version, file)
332
332
333
333
# fetches changes from a remote branch - this does not modify the working directory,
334
334
# it just gets the changes from the remote if there are any
335
- def fetch ( remote = 'origin' )
336
- self . lib . fetch ( remote )
335
+ def fetch ( remote = 'origin' , opts = { } )
336
+ self . lib . fetch ( remote , opts )
337
337
end
338
338
339
339
# pushes changes to a remote repository - easiest if this is a cloned repository,
Original file line number Diff line number Diff line change @@ -607,8 +607,11 @@ def tag(name, *opts)
607
607
end
608
608
609
609
610
- def fetch ( remote )
611
- command ( 'fetch' , remote )
610
+ def fetch ( remote , opts )
611
+ arr_opts = [ remote ]
612
+ arr_opts << '--tags' if opts [ :t ] || opts [ :tags ]
613
+
614
+ command ( 'fetch' , arr_opts )
612
615
end
613
616
614
617
def push ( remote , branch = 'master' , opts = { } )
Original file line number Diff line number Diff line change @@ -11,8 +11,8 @@ def initialize(base, name)
11
11
@fetch_opts = config [ 'fetch' ]
12
12
end
13
13
14
- def fetch
15
- @base . fetch ( @name )
14
+ def fetch ( opts = { } )
15
+ @base . fetch ( @name , opts )
16
16
end
17
17
18
18
# merge this remote locally
Original file line number Diff line number Diff line change @@ -80,6 +80,33 @@ def test_remote_fun
80
80
#puts loc.remotes.inspect
81
81
end
82
82
end
83
+
84
+ def test_fetch
85
+ in_temp_dir do |path |
86
+ loc = Git . clone ( @wbare , 'local' )
87
+ rem = Git . clone ( @wbare , 'remote' )
88
+
89
+ r = loc . add_remote ( 'testrem' , rem )
90
+
91
+ Dir . chdir ( 'remote' ) do
92
+ rem . branch ( 'testbranch' ) . in_branch ( 'tb commit' ) do
93
+ new_file ( 'test-file' , 'add file' )
94
+ rem . add
95
+ true
96
+ end
97
+ rem . branch ( 'testbranch' ) . in_branch do
98
+ rem . add_tag ( 'test-tag-in-deleted-branch' )
99
+ false
100
+ end
101
+ rem . branch ( 'testbranch' ) . delete
102
+ end
103
+
104
+ r . fetch
105
+ assert ( !loc . tags . map ( &:name ) . include? ( 'test-tag-in-deleted-branch' ) )
106
+ r . fetch :tags => true
107
+ assert ( loc . tags . map ( &:name ) . include? ( 'test-tag-in-deleted-branch' ) )
108
+ end
109
+ end
83
110
84
111
def test_push
85
112
in_temp_dir do |path |
You can’t perform that action at this time.
0 commit comments