Sha256: 33d8f898c9c1539bea6556ec08ce0fe801bcd963fa39eee4571ccefc6037f4f8

Contents?: true

Size: 1.18 KB

Versions: 102

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

require 'avm/git/auto_commit/rules/base'

module Avm
  module Git
    module AutoCommit
      module Rules
        class Manual < ::Avm::Git::AutoCommit::Rules::Base
          class WithFile < ::Avm::Git::AutoCommit::Rules::Base::WithFile
            enable_speaker

            COMMIT_FORMAT = '%h - %s (%cr)'
            SKIP_OPTION = 's'

            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

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

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

            def format_commit(commit)
              commit.format(COMMIT_FORMAT)
            end
          end
        end
      end
    end
  end
end

Version data entries

102 entries across 102 versions & 4 rubygems

Version Path
eac_tools-0.49.0 sub/avm-git/lib/avm/git/auto_commit/rules/manual.rb
eac_tools-0.48.1 sub/avm-git/lib/avm/git/auto_commit/rules/manual.rb
eac_tools-0.48.0 sub/avm-git/lib/avm/git/auto_commit/rules/manual.rb
eac_tools-0.47.2 sub/avm-git/lib/avm/git/auto_commit/rules/manual.rb
eac_tools-0.47.1 sub/avm-git/lib/avm/git/auto_commit/rules/manual.rb
avm-git-0.10.1 lib/avm/git/auto_commit/rules/manual.rb
eac_tools-0.47.0 sub/avm-git/lib/avm/git/auto_commit/rules/manual.rb
eac_tools-0.46.0 sub/avm-git/lib/avm/git/auto_commit/rules/manual.rb
eac_tools-0.45.2 sub/avm-git/lib/avm/git/auto_commit/rules/manual.rb
eac_tools-0.45.1 sub/avm-git/lib/avm/git/auto_commit/rules/manual.rb
eac_tools-0.45.0 sub/avm-git/lib/avm/git/auto_commit/rules/manual.rb
eac_tools-0.44.0 sub/avm-git/lib/avm/git/auto_commit/rules/manual.rb
eac_tools-0.43.0 sub/avm-git/lib/avm/git/auto_commit/rules/manual.rb
eac_tools-0.42.0 sub/avm-git/lib/avm/git/auto_commit/rules/manual.rb
avm-git-0.10.0 lib/avm/git/auto_commit/rules/manual.rb
eac_tools-0.41.0 sub/avm-git/lib/avm/git/auto_commit/rules/manual.rb
eac_tools-0.40.0 sub/avm-git/lib/avm/git/auto_commit/rules/manual.rb
avm-git-0.9.0 lib/avm/git/auto_commit/rules/manual.rb
eac_tools-0.39.0 sub/avm-git/lib/avm/git/auto_commit/rules/manual.rb
eac_tools-0.38.0 sub/avm-git/lib/avm/git/auto_commit/rules/manual.rb