Skip to content
Snippets Groups Projects
Commit ecc983d7 authored by Arnaud Levy's avatar Arnaud Levy
Browse files

Fix #331

parent c143e08d
No related branches found
No related tags found
No related merge requests found
......@@ -51,7 +51,12 @@ class Git::Providers::Github < Git::Providers::Abstract
end
def git_sha(path)
return if path.nil?
# Try to find in stored tree to avoid multiple queries
return hash_for_paths[path] if hash_for_paths.has_key? path
begin
# The fast way, with no query, does not work.
# Let's query the API
content = client.content repository, path: path
sha = content[:sha]
rescue
......@@ -74,6 +79,18 @@ class Git::Providers::Github < Git::Providers::Abstract
@branch_sha ||= client.branch(repository, default_branch)[:commit][:sha]
end
def hash_for_paths
unless @hash_for_paths
@hash_for_paths = {}
tree[:tree].each do |hash|
path = hash[:path]
sha = hash[:sha]
@hash_for_paths[path] = sha
end
end
@hash_for_paths
end
def tree
@tree ||= client.tree repository, branch_sha, recursive: true
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment