Skip to content

Commit f38d1c1

Browse files
Updating ls_remote doc and enabling it via Git.ls_remote
1 parent 321ecf2 commit f38d1c1

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ Here are the operations that need read permission only.
153153
g.show()
154154
g.show('HEAD')
155155
g.show('v2.8', 'README.md')
156+
157+
Git.ls_remote('https://github.com/schacon/ruby-git.git') # returns a hash containing the available references of the repo.
158+
Git.ls_remote('/path/to/local/repo')
159+
Git.ls_remote() # same as Git.ls_remote('.')
160+
156161
```
157162

158163
And here are the operations that will need to write to your git repository.

git.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Gem::Specification.new do |s|
2929
'lib/git.rb',
3030
'lib/git/author.rb',
3131
'lib/git/base.rb',
32+
'lib/git/base/factory.rb',
3233
'lib/git/branch.rb',
3334
'lib/git/branches.rb',
3435
'lib/git/config.rb',

lib/git.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,15 @@ def self.global_config(name = nil, value = nil)
139139
def self.init(working_dir = '.', options = {})
140140
Base.init(working_dir, options)
141141
end
142+
143+
# returns a Hash containing information about the references
144+
# of the target repository
145+
#
146+
# @param [String|NilClass] location the target repository location or nil for '.'
147+
# @return [{String=>Hash}] the available references of the target repo.
148+
def self.ls_remote(location=nil)
149+
Git::Lib.new.ls_remote(location)
150+
end
142151

143152
# open an existing git working directory
144153
#

lib/git/lib.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ def ls_files(location=nil)
393393
end
394394

395395
def ls_remote(location=nil)
396+
location ||= '.'
396397
Hash.new{ |h,k| h[k] = {} }.tap do |hsh|
397398
command_lines('ls-remote', [location], false).each do |line|
398399
(sha, info) = line.split("\t")

0 commit comments

Comments
 (0)