./lib/dolt/repo_actions.rb in dolt-0.2.1 vs ./lib/dolt/repo_actions.rb in dolt-0.2.2
- old
+ new
@@ -37,10 +37,24 @@
def history(repo, ref, path, count, &block)
repo_action(repo, ref, path, :commits, :log, ref, path, count, &block)
end
+ def refs(repo, &block)
+ repository = repo_resolver.resolve(repo)
+ d = repository.refs
+ d.callback do |refs|
+ names = refs.map(&:name)
+ block.call(nil, {
+ :repository => repo,
+ :tags => stripped_ref_names(names, :tags),
+ :heads => stripped_ref_names(names, :heads)
+ })
+ end
+ d.errback { |err| block.call(err, nil) }
+ end
+
def repositories
repo_resolver.all
end
private
@@ -59,8 +73,14 @@
{
:repository => repo,
:path => path,
:ref => ref
}.merge(locals)
+ end
+
+ def stripped_ref_names(names, type)
+ names.select { |n| n =~ /#{type}/ }.map do |n|
+ n.sub(/^refs\/#{type}\//, "")
+ end
end
end
end