Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.

Commit

Permalink
Updating ls_remote doc and enabling it via Git.ls_remote
Browse files Browse the repository at this point in the history
  • Loading branch information
robertodecurnex committed Jan 12, 2015
1 parent 321ecf2 commit f38d1c1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ Here are the operations that need read permission only.
g.show()
g.show('HEAD')
g.show('v2.8', 'README.md')

Git.ls_remote('https://github.com/schacon/ruby-git.git') # returns a hash containing the available references of the repo.
Git.ls_remote('/path/to/local/repo')
Git.ls_remote() # same as Git.ls_remote('.')

```

And here are the operations that will need to write to your git repository.
Expand Down
1 change: 1 addition & 0 deletions git.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Gem::Specification.new do |s|
'lib/git.rb',
'lib/git/author.rb',
'lib/git/base.rb',
'lib/git/base/factory.rb',
'lib/git/branch.rb',
'lib/git/branches.rb',
'lib/git/config.rb',
Expand Down
9 changes: 9 additions & 0 deletions lib/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ def self.global_config(name = nil, value = nil)
def self.init(working_dir = '.', options = {})
Base.init(working_dir, options)
end

# returns a Hash containing information about the references
# of the target repository
#
# @param [String|NilClass] location the target repository location or nil for '.'
# @return [{String=>Hash}] the available references of the target repo.
def self.ls_remote(location=nil)
Git::Lib.new.ls_remote(location)
end

# open an existing git working directory
#
Expand Down
1 change: 1 addition & 0 deletions lib/git/lib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ def ls_files(location=nil)
end

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

0 comments on commit f38d1c1

Please sign in to comment.