Module: Avm::Git::Issue::Complete::Commits

Defined in:
lib/avm/git/issue/complete/commits.rb

Instance Method Summary collapse

Instance Method Details

#bifurcations_resultObject



19
20
21
22
23
24
25
26
# File 'lib/avm/git/issue/complete/commits.rb', line 19

def bifurcations_result
  commits.each do |commit|
    if multiple_parents?(commit)
      return ::Avm::Result.error("#{commit} has multiple parents")
    end
  end
  ::Avm::Result.success('no')
end

#commit_parents(commit) ⇒ Object



32
33
34
35
# File 'lib/avm/git/issue/complete/commits.rb', line 32

def commit_parents(commit)
  launcher_git.execute!('log', '--pretty=%P', '-n', '1', commit).split.map(&:strip)
    .select(&:present?)
end

#commits_resultObject



8
9
10
# File 'lib/avm/git/issue/complete/commits.rb', line 8

def commits_result
  ::Avm::Result.success_or_error(commits.any?, 'yes', 'none')
end

#commits_uncachedObject



12
13
14
15
16
17
# File 'lib/avm/git/issue/complete/commits.rb', line 12

def commits_uncached
  return [] unless branch_hash && follow_master?

  interval = remote_master_hash ? "#{remote_master_hash}..#{branch_hash}" : branch_hash
  launcher_git.execute!('rev-list', interval).each_line.map(&:strip)
end

#multiple_parents?(commit) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/avm/git/issue/complete/commits.rb', line 28

def multiple_parents?(commit)
  commit_parents(commit).many?
end