Class: KnapsackPro::RepositoryAdapters::GitAdapter
- Inherits:
-
BaseAdapter
- Object
- BaseAdapter
- KnapsackPro::RepositoryAdapters::GitAdapter
- Defined in:
- lib/knapsack_pro/repository_adapters/git_adapter.rb
Instance Method Summary collapse
- #branch ⇒ Object
- #branches ⇒ Object
- #build_author ⇒ Object
- #commit_authors ⇒ Object
- #commit_hash ⇒ Object
Instance Method Details
#branch ⇒ Object
8 9 10 |
# File 'lib/knapsack_pro/repository_adapters/git_adapter.rb', line 8 def branch `git -C "#{working_dir}" rev-parse --abbrev-ref HEAD`.strip end |
#branches ⇒ Object
12 13 14 15 |
# File 'lib/knapsack_pro/repository_adapters/git_adapter.rb', line 12 def branches str_branches = `git rev-parse --abbrev-ref --branches` str_branches.split("\n") end |
#build_author ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/knapsack_pro/repository_adapters/git_adapter.rb', line 33 def = KnapsackPro::MaskString.call(.strip) raise if .empty? rescue Exception "no git <no.git@example.com>" end |
#commit_authors ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/knapsack_pro/repository_adapters/git_adapter.rb', line 17 def = .split("\n") .map { |line| line.strip } .map { |line| line.split("\t") } .map do |commits, | { commits: commits.to_i, author: KnapsackPro::MaskString.call() } end raise if .empty? rescue Exception [] end |
#commit_hash ⇒ Object
4 5 6 |
# File 'lib/knapsack_pro/repository_adapters/git_adapter.rb', line 4 def commit_hash `git -C "#{working_dir}" rev-parse HEAD`.strip end |