lib/git/lint/cli.rb in git-lint-1.4.0 vs lib/git/lint/cli.rb in git-lint-2.0.0
- old
+ new
@@ -1,10 +1,11 @@
# frozen_string_literal: true
require "thor"
require "thor/actions"
require "runcom"
+require "pathname"
require "pastel"
module Git
module Lint
# The Command Line Interface (CLI) for the gem.
@@ -58,11 +59,13 @@
aliases: "-c",
desc: "Analyze specific commit SHA(s).",
type: :array,
default: []
def analyze
- collector = analyze_commits options.commits
+ # FIX: Need to accept SHAs.
+ # collector = analyze_commits options.commits
+ collector = analyze_commits
abort if collector.errors?
rescue Errors::Base => error
abort colorizer.red("#{Identity::LABEL}: #{error.message}")
end
@@ -76,11 +79,11 @@
if options.commit_message?
check_commit_message options.commit_message
else
help "--hook"
end
- rescue Errors::Base => error
+ rescue Errors::Base, GitPlus::Errors::Base => error
abort colorizer.red("#{Identity::LABEL}: #{error.message}")
end
desc "-v, [--version]", "Show gem version."
map %w[-v --version] => :version
@@ -96,24 +99,19 @@
private
attr_reader :configuration, :runner, :colorizer
- def load_collector shas
- commits = shas.map { |sha| Commits::Saved.new sha: sha }
- commits.empty? ? runner.call : runner.call(commits: commits)
- end
-
- def analyze_commits shas
- load_collector(shas).tap do |collector|
+ def analyze_commits
+ runner.call.tap do |collector|
reporter = Reporters::Branch.new collector: collector
say reporter.to_s
end
end
def check_commit_message path
- commit = Commits::Unsaved.new path: path
- collector = runner.call commits: commit
+ commit = GitPlus::Repository.new.unsaved Pathname(path)
+ collector = runner.call commits: [commit]
reporter = Reporters::Branch.new collector: collector
say reporter.to_s
abort if collector.errors?
end
end