Sha256: c3c189e96b63065d29f6c7ca5e95c7a8bb81fd936dba0f3c78eee9c789c95f41

Contents?: true

Size: 899 Bytes

Versions: 11

Compression:

Stored size: 899 Bytes

Contents

# frozen_string_literal: true

require "sod"
require "sod/types/pathname"

module Git
  module Lint
    module CLI
      module Actions
        # Handles unsaved Git commit action.
        class Hook < Sod::Action
          include Git::Lint::Import[:git, :kernel, :logger]

          description "Hook for analyzing unsaved commits."

          on "--hook", argument: "PATH", type: Pathname

          def initialize(analyzer: Analyzer.new, **)
            super(**)
            @analyzer = analyzer
          end

          def call path
            analyzer.call commits: commits(path) do |collector, reporter|
              kernel.puts reporter
              kernel.abort if collector.errors?
            end
          end

          private

          attr_reader :analyzer

          def commits(path) = git.uncommitted(path).fmap { |commit| [commit] }
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
git-lint-7.5.0 lib/git/lint/cli/actions/hook.rb
git-lint-7.3.0 lib/git/lint/cli/actions/hook.rb
git-lint-7.2.0 lib/git/lint/cli/actions/hook.rb
git-lint-7.1.0 lib/git/lint/cli/actions/hook.rb
git-lint-7.0.0 lib/git/lint/cli/actions/hook.rb
git-lint-6.2.1 lib/git/lint/cli/actions/hook.rb
git-lint-6.2.0 lib/git/lint/cli/actions/hook.rb
git-lint-6.1.0 lib/git/lint/cli/actions/hook.rb
git-lint-6.0.2 lib/git/lint/cli/actions/hook.rb
git-lint-6.0.1 lib/git/lint/cli/actions/hook.rb
git-lint-6.0.0 lib/git/lint/cli/actions/hook.rb