Skip to content
This repository has been archived by the owner on May 12, 2018. It is now read-only.

Commit

Permalink
Merge ca14f02 into bb351d2
Browse files Browse the repository at this point in the history
  • Loading branch information
koreamic committed Dec 7, 2015
2 parents bb351d2 + ca14f02 commit 7f41e16
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lib/gitlab_git/repository.rb
Expand Up @@ -807,6 +807,32 @@ def autocrlf=(value)
rugged.config['core.autocrlf'] = AUTOCRLF_VALUES.invert[value]
end

# Return result like "git ls-files" , recursive and full file path only
#
# Ex.
# repo.ls_files('master')
#
def ls_files(ref)
actual_ref = ref || root_ref

begin
sha = sha_from_ref(actual_ref)
rescue Rugged::OdbError, Rugged::InvalidError, Rugged::ReferenceError
# Return an empty array if the ref wasn't found
return []
end

cmd = %W(git --git-dir=#{path} ls-tree)
cmd += %W(-r)
cmd += %W(--full-tree)
cmd += %W(--full-name)
cmd += %W(--name-only)
cmd += %W(-- #{actual_ref})
raw_output = IO.popen(cmd) {|io| io.read }

raw_output.split("\n")
end

private

# Get the content of a blob for a given commit. If the blob is a commit
Expand Down

0 comments on commit 7f41e16

Please sign in to comment.