Class: Avm::Git::AutoCommit::Rules::Manual::WithFile
- Inherits:
-
Base::WithFile
- Object
- Base::WithFile
- Avm::Git::AutoCommit::Rules::Manual::WithFile
- Defined in:
- lib/avm/git/auto_commit/rules/manual.rb
Constant Summary collapse
- COMMIT_FORMAT =
'%h - %s (%cr)'
- SKIP_OPTION =
's'
Instance Method Summary collapse
- #commit_info ⇒ Object
- #commits_banner ⇒ Object
- #commits_by_position ⇒ Object
- #format_commit(commit) ⇒ Object
Methods inherited from Base::WithFile
Instance Method Details
#commit_info ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/avm/git/auto_commit/rules/manual.rb', line 16 def commit_info return nil unless file.commits.any? input('Which commit?', list: commits_by_position).if_present do |v| new_commit_info.fixup(v) end end |
#commits_banner ⇒ Object
25 26 27 28 29 30 |
# File 'lib/avm/git/auto_commit/rules/manual.rb', line 25 def file.commits.each_with_index do |commit, _index| infov " #{commit.position}", format_commit(commit) end infov " #{SKIP_OPTION}", 'skip' end |
#commits_by_position ⇒ Object
32 33 34 35 |
# File 'lib/avm/git/auto_commit/rules/manual.rb', line 32 def commits_by_position (file.commits.map { |commit| [commit.position.to_s, commit] } + [[SKIP_OPTION, nil]]) .to_h end |
#format_commit(commit) ⇒ Object
37 38 39 |
# File 'lib/avm/git/auto_commit/rules/manual.rb', line 37 def format_commit(commit) commit.format(COMMIT_FORMAT) end |