Class: Avm::Scms::AutoCommit::Rules::Manual::WithFile

Inherits:
Base::WithFile
  • Object
show all
Defined in:
lib/avm/scms/auto_commit/rules/manual.rb

Constant Summary collapse

SKIP_OPTION =
's'

Instance Method Summary collapse

Methods inherited from Base::WithFile

#new_commit_info

Instance Method Details

#commit_infoObject



15
16
17
18
19
20
21
22
# File 'lib/avm/scms/auto_commit/rules/manual.rb', line 15

def commit_info
  return nil unless file.commits.any?

  commits_banner
  input('Which commit?', list: commits_by_position).if_present do |v|
    new_commit_info.fixup(v)
  end
end

#commits_bannerObject



24
25
26
27
28
29
# File 'lib/avm/scms/auto_commit/rules/manual.rb', line 24

def commits_banner
  file.commits.each_with_index do |commit, _index|
    infov "    #{commit.position}", commit
  end
  infov "    #{SKIP_OPTION}", 'skip'
end

#commits_by_positionObject



31
32
33
34
# File 'lib/avm/scms/auto_commit/rules/manual.rb', line 31

def commits_by_position
  (file.commits.map { |commit| [commit.position.to_s, commit] } + [[SKIP_OPTION, nil]])
    .to_h
end