Class: KnapsackPro::RepositoryAdapters::GitAdapter

Inherits:
BaseAdapter
  • Object
show all
Defined in:
lib/knapsack_pro/repository_adapters/git_adapter.rb

Instance Method Summary collapse

Instance Method Details

#branchObject



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

#branchesObject



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_authorObject



33
34
35
36
37
38
39
# File 'lib/knapsack_pro/repository_adapters/git_adapter.rb', line 33

def build_author
  author = KnapsackPro::MaskString.call(git_build_author.strip)
  raise if author.empty?
  author
rescue Exception
  "no git <no.git@example.com>"
end

#commit_authorsObject



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 commit_authors
  authors = git_commit_authors
    .split("\n")
    .map { |line| line.strip }
    .map { |line| line.split("\t") }
    .map do |commits, author|
      { commits: commits.to_i, author: KnapsackPro::MaskString.call(author) }
    end

  raise if authors.empty?

  authors
rescue Exception
  []
end

#commit_hashObject



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