File tree 3 files changed +60
-3
lines changed 3 files changed +60
-3
lines changed Original file line number Diff line number Diff line change @@ -504,8 +504,21 @@ def write_and_commit_tree(opts = {})
504
504
def update_ref ( branch , commit )
505
505
branch ( branch ) . update_ref ( commit )
506
506
end
507
-
508
-
507
+
508
+ def ls_remote ( location = nil , opts = { } )
509
+ tmp = self . lib . ls_remote ( location , opts )
510
+ if ( opts [ :tags ] )
511
+ ret = [ ]
512
+ tmp . each { |line |
513
+ split = line . split
514
+ short_name = split [ 1 ] . sub ( /refs\/ tags\/ / , '' )
515
+ obj = { :sha => split [ 0 ] , :tag_ref => split [ 1 ] , :name => short_name }
516
+ ret . push obj
517
+ }
518
+ return ret
519
+ end
520
+ end
521
+
509
522
def ls_files ( location = nil )
510
523
self . lib . ls_files ( location )
511
524
end
Original file line number Diff line number Diff line change @@ -305,7 +305,14 @@ def diff_files
305
305
def diff_index ( treeish )
306
306
diff_as_hash ( 'diff-index' , treeish )
307
307
end
308
-
308
+
309
+ def ls_remote ( location = nil , opts = { } )
310
+ args = [ ]
311
+ args << ( opts [ :tags ] ? '--tags' : '' )
312
+ args << location
313
+ command_lines ( 'ls-remote' , args )
314
+ end
315
+
309
316
def ls_files ( location = nil )
310
317
hsh = { }
311
318
command_lines ( 'ls-files' , [ '--stage' , location ] ) . each do |line |
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env ruby
2
+
3
+ require File . dirname ( __FILE__ ) + '/../test_helper'
4
+
5
+ class TestRemoteLs < Test ::Unit ::TestCase
6
+ def setup
7
+ set_file_paths
8
+ end
9
+
10
+ def test_remote_ls_tags
11
+ in_temp_dir do |path |
12
+ r1 = Git . clone ( @wbare , 'repo1' )
13
+ r2 = Git . clone ( @wbare , 'repo2' )
14
+
15
+ # setup
16
+ r1 . add_remote ( 'r2' , r2 )
17
+ r1 . add_tag ( 'foo_bar_baz' )
18
+
19
+ tags = r1 . ls_remote ( 'r2' , { :tags => true } )
20
+ tags . each { |t |
21
+ assert_false t . has_value? 'foo_bar_baz'
22
+ }
23
+
24
+ r1 . push ( 'origin' , 'master' , { :tags => true } )
25
+ r1 . push ( 'r2' , 'master' , { :tags => true } )
26
+ tags = r1 . ls_remote ( 'r2' , { :tags => true } )
27
+
28
+ found = false
29
+ tags . each { |t |
30
+ if t . has_value? 'foo_bar_baz'
31
+ found = true
32
+ end
33
+ }
34
+ assert found === true
35
+ end
36
+ end
37
+ end
You can’t perform that action at this time.
0 commit comments