Class: Dolt::Git::Repository
- Inherits:
-
Object
- Object
- Dolt::Git::Repository
- Defined in:
- lib/libdolt/git/repository.rb
Instance Method Summary collapse
- #bare? ⇒ Boolean
- #blame(ref, blob_path) ⇒ Object
- #blob(ref, path) ⇒ Object
-
#initialize(root) ⇒ Repository
constructor
A new instance of Repository.
- #log(ref, path, limit) ⇒ Object
- #lookup(*args) ⇒ Object
- #path ⇒ Object
- #readmes(ref, path = "") ⇒ Object
- #refs(*args) ⇒ Object
- #rev_parse(*args) ⇒ Object
- #rev_parse_oid(*args) ⇒ Object
- #submodules(ref) ⇒ Object
- #tree(ref, path) ⇒ Object
- #tree_entry(ref, path) ⇒ Object
- #tree_history(ref, path, limit = 1) ⇒ Object
Constructor Details
#initialize(root) ⇒ Repository
Returns a new instance of Repository.
28 29 30 |
# File 'lib/libdolt/git/repository.rb', line 28 def initialize(root) @repo = Rugged::Repository.new(root) end |
Instance Method Details
#bare? ⇒ Boolean
32 |
# File 'lib/libdolt/git/repository.rb', line 32 def ; @repo.; end |
#blame(ref, blob_path) ⇒ Object
61 62 63 64 |
# File 'lib/libdolt/git/repository.rb', line 61 def blame(ref, blob_path) process = Dolt::Git.git(path, "blame -l -t -p #{ref} -- #{blob_path}") Dolt::Git::Blame.parse_porcelain(process.stdout.read) end |
#blob(ref, path) ⇒ Object
47 48 49 |
# File 'lib/libdolt/git/repository.rb', line 47 def blob(ref, path) rev_parse("#{ref}:#{path}") end |
#log(ref, path, limit) ⇒ Object
66 67 68 |
# File 'lib/libdolt/git/repository.rb', line 66 def log(ref, path, limit) entry_history(ref, path, limit) end |
#lookup(*args) ⇒ Object
37 |
# File 'lib/libdolt/git/repository.rb', line 37 def lookup(*args); @repo.lookup(*args); end |
#path ⇒ Object
33 |
# File 'lib/libdolt/git/repository.rb', line 33 def path; @repo.path; end |
#readmes(ref, path = "") ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/libdolt/git/repository.rb', line 81 def readmes(ref, path="") tree(ref, path).entries.select do |e| e[:type] == :blob && e[:name].match(/readme/i) end rescue Exception => err [] end |
#refs(*args) ⇒ Object
36 |
# File 'lib/libdolt/git/repository.rb', line 36 def refs(*args); @repo.refs(*args); end |
#rev_parse(*args) ⇒ Object
34 |
# File 'lib/libdolt/git/repository.rb', line 34 def rev_parse(*args); @repo.rev_parse(*args); end |
#rev_parse_oid(*args) ⇒ Object
35 |
# File 'lib/libdolt/git/repository.rb', line 35 def rev_parse_oid(*args); @repo.rev_parse_oid(*args); end |
#submodules(ref) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/libdolt/git/repository.rb', line 39 def submodules(ref) config = rev_parse("#{ref}:.gitmodules") Dolt::Git::Submodule.parse_config(config.content) rescue Rugged::TreeError => err # Raised if .gitmodules cannot be found, which means no submodules [] end |
#tree(ref, path) ⇒ Object
51 52 53 54 55 |
# File 'lib/libdolt/git/repository.rb', line 51 def tree(ref, path) object = rev_parse("#{ref}:#{path}") raise StandardError.new("Not a tree") if !object.is_a?(Rugged::Tree) annotate_tree(ref, path, object) end |
#tree_entry(ref, path) ⇒ Object
57 58 59 |
# File 'lib/libdolt/git/repository.rb', line 57 def tree_entry(ref, path) annotate_tree(ref, path, rev_parse("#{ref}:#{path}")) end |
#tree_history(ref, path, limit = 1) ⇒ Object
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/libdolt/git/repository.rb', line 70 def tree_history(ref, path, limit = 1) tree = rev_parse("#{ref}:#{path}") if tree.class != Rugged::Tree = "#{ref}:#{path} is not a tree (#{tree.class.to_s})" raise Exception.new() end annotate_history(path || "./", ref, tree, limit) end |