2

In a bare repository I can type $ git ls-tree -r master. (this is sort of the same thing I can get in a none-bare repos with the command git ls-files )

for a full list of files and their sha refs in a git repository.

With Rugged, how do I get that list of files in a particular branch or master?

Jesper Rønn-Jensen
  • 106,591
  • 44
  • 118
  • 155

2 Answers2

2

What you're looking for is rugged's Tree object. If you have a commit, say from commit = repo.head.target, you can get the files in that commit's tree by accessing it as an array:

tree = commit.tree
puts tree[0].filename

See https://github.com/libgit2/rugged#tree-objects for more examples

ComputerDruid
  • 16,897
  • 1
  • 19
  • 28
0

In rugged 1.2.0 you can do:

repo.index.entries.map { |e| e[:path] }
builder-7000
  • 7,131
  • 3
  • 19
  • 43