git-lint 1.4.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +2 -3
  4. data/lib/git/lint.rb +1 -3
  5. data/lib/git/lint/analyzers/abstract.rb +3 -3
  6. data/lib/git/lint/analyzers/commit_author_name.rb +1 -1
  7. data/lib/git/lint/analyzers/commit_body_leading_line.rb +3 -3
  8. data/lib/git/lint/analyzers/commit_subject_prefix.rb +1 -1
  9. data/lib/git/lint/analyzers/commit_trailer_collaborator_capitalization.rb +2 -2
  10. data/lib/git/lint/analyzers/commit_trailer_collaborator_duplication.rb +3 -3
  11. data/lib/git/lint/analyzers/commit_trailer_collaborator_email.rb +2 -2
  12. data/lib/git/lint/analyzers/commit_trailer_collaborator_key.rb +2 -2
  13. data/lib/git/lint/analyzers/commit_trailer_collaborator_name.rb +2 -2
  14. data/lib/git/lint/branches/environments/circle_ci.rb +6 -6
  15. data/lib/git/lint/branches/environments/git_hub_action.rb +6 -6
  16. data/lib/git/lint/branches/environments/local.rb +6 -6
  17. data/lib/git/lint/branches/environments/netlify_ci.rb +8 -8
  18. data/lib/git/lint/branches/environments/travis_ci.rb +10 -10
  19. data/lib/git/lint/branches/feature.rb +6 -7
  20. data/lib/git/lint/cli.rb +9 -11
  21. data/lib/git/lint/collector.rb +3 -3
  22. data/lib/git/lint/identity.rb +1 -1
  23. data/lib/git/lint/parsers/trailers/collaborator.rb +2 -2
  24. data/lib/git/lint/reporters/branch.rb +14 -14
  25. data/lib/git/lint/runner.rb +5 -4
  26. data/lib/git/lint/validators/capitalization.rb +1 -1
  27. data/lib/git/lint/validators/name.rb +1 -1
  28. metadata +22 -11
  29. metadata.gz.sig +2 -2
  30. data/lib/git/kit/repo.rb +0 -30
  31. data/lib/git/lint/commits/saved.rb +0 -104
  32. data/lib/git/lint/commits/unsaved.rb +0 -120
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6cb65f70f2b6923d02f717470a175b4a12f4aadf8f138ce2687ebdd73be3d300
4
- data.tar.gz: 69a3dae72502594bd98c0397c29431bbfa4479fc6b5cebe8e76ce4149505085d
3
+ metadata.gz: 0f890a2d629a880fe71b362f043772b891e8bb6610eeafac4ce7d68f20ccc636
4
+ data.tar.gz: d8e5e33287b6e4be9787a7d1c9ee8d4bc45a7df5de993b52b732b2de56fa1981
5
5
  SHA512:
6
- metadata.gz: 516084aa71ca86ec7fb5b4acbbc5eac343d6c4d44cc01ea8742c7882a3c203bafb9108fa788f0a00c4874bca40e810080b9b84d5d3ae583585e6efdef8166eb2
7
- data.tar.gz: 1dbdb7ecf79311784ef01ede90695df2093fbd7d43b918e39d6bb596843bbaa87d6df59a8f57a901a8fdfb4cc5a935d92d7ad69bdde5f24ba0859f8d5efdb92f
6
+ metadata.gz: a019791e28fe05d1bf198d60c5b8516481e68e1658dc1749d3b4a8c355d128c1f64f472d56b76c57305e2f0d58a2cf2ca6af86fe6fbd978f020d6bc60b2233b4
7
+ data.tar.gz: a10d7d047daff9d31d88fd53a435f12445e59013bc16df30ad877d7738d12ec45acead33e916c7dd122e527b48faea066a332fbe43b454e2ffec76602089e1b0
Binary file
data.tar.gz.sig CHANGED
@@ -1,3 +1,2 @@
1
- ��)�*4�>{��K��O��B
2
- m����8��Tsb��j�Ҹ���~���댙k}H�� 2?��H�]�Xq> Pa�wN�Vv��T��X㥇���Bı���jz8��;�
3
-  �Kؗ��*o4ؿ�b�wNN�����p}֎@�",�b�\�3�EN̅�L�*j��O���b}�ӅM9��ěe H�˳�P
1
+ ���;��
2
+ $�#6l��H�A�ܳ?��
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "git_plus"
3
4
  require "git/lint/identity"
4
- require "git/kit/repo"
5
5
  require "git/lint/refinements/strings"
6
6
  require "git/lint/errors/base"
7
7
  require "git/lint/errors/severity"
@@ -11,8 +11,6 @@ require "git/lint/validators/email"
11
11
  require "git/lint/validators/name"
12
12
  require "git/lint/validators/capitalization"
13
13
  require "git/lint/parsers/trailers/collaborator"
14
- require "git/lint/commits/saved"
15
- require "git/lint/commits/unsaved"
16
14
  require "git/lint/branches/environments/local"
17
15
  require "git/lint/branches/environments/circle_ci"
18
16
  require "git/lint/branches/environments/git_hub_action"
@@ -91,10 +91,10 @@ module Git
91
91
  end
92
92
  end
93
93
 
94
- def affected_commit_trailer_lines
95
- commit.trailer_lines
94
+ def affected_commit_trailers
95
+ commit.trailers
96
96
  .each.with_object([])
97
- .with_index(commit.trailer_index) do |(line, lines), index|
97
+ .with_index(commit.trailers_index) do |(line, lines), index|
98
98
  yield if block_given?
99
99
  lines << self.class.build_issue_line(index, line) if invalid_line? line
100
100
  end
@@ -32,7 +32,7 @@ module Git
32
32
  attr_reader :validator
33
33
 
34
34
  def minimum
35
- settings.fetch :minimum
35
+ settings.fetch __method__
36
36
  end
37
37
  end
38
38
  end
@@ -12,12 +12,12 @@ module Git
12
12
  end
13
13
 
14
14
  def valid?
15
- raw_body = commit.raw_body
16
- subject, body = raw_body.split "\n", 2
15
+ message = commit.message
16
+ subject, body = message.split "\n", 2
17
17
 
18
18
  return true if !String(subject).empty? && String(body).strip.empty?
19
19
 
20
- raw_body.match?(/\A.+(\n\n|\#).+/m)
20
+ message.match?(/\A.+(\n\n|\#).+/m)
21
21
  end
22
22
 
23
23
  def issue
@@ -34,7 +34,7 @@ module Git
34
34
  private
35
35
 
36
36
  def fixup_or_squash?
37
- commit.is_a?(Git::Lint::Commits::Unsaved) && (commit.fixup? || commit.squash?)
37
+ commit.fixup? || commit.squash?
38
38
  end
39
39
  end
40
40
  end
@@ -23,7 +23,7 @@ module Git
23
23
  # rubocop:enable Metrics/ParameterLists
24
24
 
25
25
  def valid?
26
- affected_commit_trailer_lines.empty?
26
+ affected_commit_trailers.empty?
27
27
  end
28
28
 
29
29
  def issue
@@ -31,7 +31,7 @@ module Git
31
31
 
32
32
  {
33
33
  hint: "Name must be capitalized.",
34
- lines: affected_commit_trailer_lines
34
+ lines: affected_commit_trailers
35
35
  }
36
36
  end
37
37
 
@@ -20,7 +20,7 @@ module Git
20
20
  end
21
21
 
22
22
  def valid?
23
- affected_commit_trailer_lines.empty?
23
+ affected_commit_trailers.empty?
24
24
  end
25
25
 
26
26
  def issue
@@ -28,7 +28,7 @@ module Git
28
28
 
29
29
  {
30
30
  hint: "Avoid duplication.",
31
- lines: affected_commit_trailer_lines
31
+ lines: affected_commit_trailers
32
32
  }
33
33
  end
34
34
 
@@ -47,7 +47,7 @@ module Git
47
47
  zeros = Hash.new { |new_hash, missing_key| new_hash[missing_key] = 0 }
48
48
 
49
49
  zeros.tap do |collection|
50
- commit.trailer_lines.each { |line| collection[line] += 1 if parser.new(line).match? }
50
+ commit.trailers.each { |line| collection[line] += 1 if parser.new(line).match? }
51
51
  end
52
52
  end
53
53
  end
@@ -24,7 +24,7 @@ module Git
24
24
  # rubocop:enable Metrics/ParameterLists
25
25
 
26
26
  def valid?
27
- affected_commit_trailer_lines.empty?
27
+ affected_commit_trailers.empty?
28
28
  end
29
29
 
30
30
  def issue
@@ -32,7 +32,7 @@ module Git
32
32
 
33
33
  {
34
34
  hint: %(Email must follow name and use format: "<name@server.domain>".),
35
- lines: affected_commit_trailer_lines
35
+ lines: affected_commit_trailers
36
36
  }
37
37
  end
38
38
 
@@ -20,7 +20,7 @@ module Git
20
20
  end
21
21
 
22
22
  def valid?
23
- affected_commit_trailer_lines.empty?
23
+ affected_commit_trailers.empty?
24
24
  end
25
25
 
26
26
  def issue
@@ -28,7 +28,7 @@ module Git
28
28
 
29
29
  {
30
30
  hint: "Use format: #{filter_list.to_hint}.",
31
- lines: affected_commit_trailer_lines
31
+ lines: affected_commit_trailers
32
32
  }
33
33
  end
34
34
 
@@ -25,7 +25,7 @@ module Git
25
25
  # rubocop:enable Metrics/ParameterLists
26
26
 
27
27
  def valid?
28
- affected_commit_trailer_lines.empty?
28
+ affected_commit_trailers.empty?
29
29
  end
30
30
 
31
31
  def issue
@@ -33,7 +33,7 @@ module Git
33
33
 
34
34
  {
35
35
  hint: "Name must follow key and consist of #{minimum} parts (minimum).",
36
- lines: affected_commit_trailer_lines
36
+ lines: affected_commit_trailers
37
37
  }
38
38
  end
39
39
 
@@ -6,21 +6,21 @@ module Git
6
6
  module Environments
7
7
  # Provides Circle CI build environment feature branch information.
8
8
  class CircleCI
9
- def initialize repo: Git::Kit::Repo.new
10
- @repo = repo
9
+ def initialize repository: GitPlus::Repository.new
10
+ @repository = repository
11
11
  end
12
12
 
13
13
  def name
14
- "origin/#{repo.branch_name}"
14
+ "origin/#{repository.branch_name}"
15
15
  end
16
16
 
17
- def shas
18
- repo.shas start: "origin/master", finish: name
17
+ def commits
18
+ repository.commits "origin/master..#{name}"
19
19
  end
20
20
 
21
21
  private
22
22
 
23
- attr_reader :repo
23
+ attr_reader :repository
24
24
  end
25
25
  end
26
26
  end
@@ -6,21 +6,21 @@ module Git
6
6
  module Environments
7
7
  # Provides GitHub Action build environment feature branch information.
8
8
  class GitHubAction
9
- def initialize repo: Git::Kit::Repo.new
10
- @repo = repo
9
+ def initialize repository: GitPlus::Repository.new
10
+ @repository = repository
11
11
  end
12
12
 
13
13
  def name
14
- "origin/#{repo.branch_name}"
14
+ "origin/#{repository.branch_name}"
15
15
  end
16
16
 
17
- def shas
18
- repo.shas start: "origin/master", finish: name
17
+ def commits
18
+ repository.commits "origin/master..#{name}"
19
19
  end
20
20
 
21
21
  private
22
22
 
23
- attr_reader :repo
23
+ attr_reader :repository
24
24
  end
25
25
  end
26
26
  end
@@ -6,21 +6,21 @@ module Git
6
6
  module Environments
7
7
  # Provides local build environment feature branch information.
8
8
  class Local
9
- def initialize repo: Git::Kit::Repo.new
10
- @repo = repo
9
+ def initialize repository: GitPlus::Repository.new
10
+ @repository = repository
11
11
  end
12
12
 
13
13
  def name
14
- repo.branch_name
14
+ repository.branch_name
15
15
  end
16
16
 
17
- def shas
18
- repo.shas start: "master", finish: name
17
+ def commits
18
+ repository.commits "master..#{name}"
19
19
  end
20
20
 
21
21
  private
22
22
 
23
- attr_reader :repo
23
+ attr_reader :repository
24
24
  end
25
25
  end
26
26
  end
@@ -8,25 +8,25 @@ module Git
8
8
  module Environments
9
9
  # Provides Netlify CI build environment feature branch information.
10
10
  class NetlifyCI
11
- def initialize environment: ENV, repo: Git::Kit::Repo.new, shell: Open3
12
- @environment = environment
13
- @repo = repo
11
+ def initialize repository: GitPlus::Repository.new, shell: Open3, environment: ENV
12
+ @repository = repository
14
13
  @shell = shell
14
+ @environment = environment
15
15
  end
16
16
 
17
17
  def name
18
18
  environment["HEAD"]
19
19
  end
20
20
 
21
- def shas
22
- shell.capture2e "git remote add -f origin #{environment["REPOSITORY_URL"]}"
23
- shell.capture2e "git fetch origin #{name}:#{name}"
24
- repo.shas start: "origin/master", finish: "origin/#{name}"
21
+ def commits
22
+ shell.capture3 "git remote add -f origin #{environment["REPOSITORY_URL"]}"
23
+ shell.capture3 "git fetch origin #{name}:#{name}"
24
+ repository.commits "origin/master..origin/#{name}"
25
25
  end
26
26
 
27
27
  private
28
28
 
29
- attr_reader :environment, :repo, :shell
29
+ attr_reader :repository, :shell, :environment
30
30
  end
31
31
  end
32
32
  end
@@ -8,35 +8,35 @@ module Git
8
8
  module Environments
9
9
  # Provides Travis CI build environment feature branch information.
10
10
  class TravisCI
11
- def initialize environment: ENV, repo: Git::Kit::Repo.new, shell: Open3
12
- @environment = environment
13
- @repo = repo
11
+ def initialize repository: GitPlus::Repository.new, shell: Open3, environment: ENV
12
+ @repository = repository
14
13
  @shell = shell
14
+ @environment = environment
15
15
  end
16
16
 
17
17
  def name
18
18
  pull_request_branch.empty? ? ci_branch : pull_request_branch
19
19
  end
20
20
 
21
- def shas
21
+ def commits
22
22
  prepare_project
23
- repo.shas start: "origin/master", finish: name
23
+ repository.commits "origin/master..#{name}"
24
24
  end
25
25
 
26
26
  private
27
27
 
28
- attr_reader :environment, :repo, :shell
28
+ attr_reader :environment, :repository, :shell
29
29
 
30
30
  def prepare_project
31
31
  slug = pull_request_slug
32
32
 
33
33
  unless slug.empty?
34
- shell.capture2e "git remote add -f original_branch https://github.com/#{slug}.git"
35
- shell.capture2e "git fetch original_branch #{name}:#{name}"
34
+ shell.capture3 "git remote add -f original_branch https://github.com/#{slug}.git"
35
+ shell.capture3 "git fetch original_branch #{name}:#{name}"
36
36
  end
37
37
 
38
- shell.capture2e "git remote set-branches --add origin master"
39
- shell.capture2e "git fetch"
38
+ shell.capture3 "git remote set-branches --add origin master"
39
+ shell.capture3 "git fetch"
40
40
  end
41
41
 
42
42
  def ci_branch
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "forwardable"
4
+ require "refinements/strings"
4
5
 
5
6
  module Git
6
7
  module Lint
@@ -9,9 +10,11 @@ module Git
9
10
  class Feature
10
11
  extend Forwardable
11
12
 
12
- def_delegators :selected_environment, :name, :shas
13
+ using ::Refinements::Strings
13
14
 
14
- def initialize environment: ENV, git_repo: Git::Kit::Repo.new
15
+ def_delegators :selected_environment, :name, :commits
16
+
17
+ def initialize environment: ENV, git_repo: GitPlus::Repository.new
15
18
  message = "Invalid repository. Are you within a Git-enabled project?"
16
19
  fail Errors::Base, message unless git_repo.exist?
17
20
 
@@ -19,10 +22,6 @@ module Git
19
22
  @selected_environment = load_environment
20
23
  end
21
24
 
22
- def commits
23
- shas.map { |sha| Commits::Saved.new sha: sha }
24
- end
25
-
26
25
  private
27
26
 
28
27
  attr_reader :current_environment, :selected_environment
@@ -37,7 +36,7 @@ module Git
37
36
  end
38
37
 
39
38
  def key? key
40
- current_environment[key] == "true"
39
+ current_environment.fetch(key, "false").to_bool
41
40
  end
42
41
  end
43
42
  end
@@ -3,6 +3,7 @@
3
3
  require "thor"
4
4
  require "thor/actions"
5
5
  require "runcom"
6
+ require "pathname"
6
7
  require "pastel"
7
8
 
8
9
  module Git
@@ -60,7 +61,9 @@ module Git
60
61
  type: :array,
61
62
  default: []
62
63
  def analyze
63
- collector = analyze_commits options.commits
64
+ # FIX: Need to accept SHAs.
65
+ # collector = analyze_commits options.commits
66
+ collector = analyze_commits
64
67
  abort if collector.errors?
65
68
  rescue Errors::Base => error
66
69
  abort colorizer.red("#{Identity::LABEL}: #{error.message}")
@@ -78,7 +81,7 @@ module Git
78
81
  else
79
82
  help "--hook"
80
83
  end
81
- rescue Errors::Base => error
84
+ rescue Errors::Base, GitPlus::Errors::Base => error
82
85
  abort colorizer.red("#{Identity::LABEL}: #{error.message}")
83
86
  end
84
87
 
@@ -98,21 +101,16 @@ module Git
98
101
 
99
102
  attr_reader :configuration, :runner, :colorizer
100
103
 
101
- def load_collector shas
102
- commits = shas.map { |sha| Commits::Saved.new sha: sha }
103
- commits.empty? ? runner.call : runner.call(commits: commits)
104
- end
105
-
106
- def analyze_commits shas
107
- load_collector(shas).tap do |collector|
104
+ def analyze_commits
105
+ runner.call.tap do |collector|
108
106
  reporter = Reporters::Branch.new collector: collector
109
107
  say reporter.to_s
110
108
  end
111
109
  end
112
110
 
113
111
  def check_commit_message path
114
- commit = Commits::Unsaved.new path: path
115
- collector = runner.call commits: commit
112
+ commit = GitPlus::Repository.new.unsaved Pathname(path)
113
+ collector = runner.call commits: [commit]
116
114
  reporter = Reporters::Branch.new collector: collector
117
115
  say reporter.to_s
118
116
  abort if collector.errors?
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "refinements/strings"
3
+ require "refinements/hashes"
4
4
 
5
5
  module Git
6
6
  module Lint
7
7
  class Collector
8
- using Refinements::Strings
8
+ using ::Refinements::Hashes
9
9
 
10
10
  def initialize
11
- @collection = Hash.new { |default, missing_id| default[missing_id] = [] }
11
+ @collection = Hash.with_default []
12
12
  end
13
13
 
14
14
  def add analyzer
@@ -6,7 +6,7 @@ module Git
6
6
  module Identity
7
7
  NAME = "git-lint"
8
8
  LABEL = "Git Lint"
9
- VERSION = "1.4.0"
9
+ VERSION = "2.0.0"
10
10
  VERSION_LABEL = "#{LABEL} #{VERSION}"
11
11
  end
12
12
  end
@@ -5,7 +5,7 @@ module Git
5
5
  module Parsers
6
6
  module Trailers
7
7
  class Collaborator
8
- DEFAULT_KEY_PATTERN = /\ACo.*Authored.*By.*\Z/i.freeze
8
+ DEFAULT_KEY_PATTERN = /\ACo.*Authored.*By.*\Z/i
9
9
 
10
10
  DEFAULT_MATCH_PATTERN = /
11
11
  (?<key>\A.+) # Key (anchored to start of line).
@@ -15,7 +15,7 @@ module Git
15
15
  (?<name_space>\s?) # Space delimiter (optional).
16
16
  (?<email><.+>)? # Collaborator email (optional).
17
17
  \Z # End of line.
18
- /x.freeze
18
+ /x
19
19
 
20
20
  def initialize text,
21
21
  key_pattern: DEFAULT_KEY_PATTERN,
@@ -23,22 +23,30 @@ module Git
23
23
 
24
24
  attr_reader :collector, :colorizer
25
25
 
26
+ def branch_report
27
+ return "" unless collector.issues?
28
+
29
+ "\n\n#{commit_report}".chomp
30
+ end
31
+
26
32
  def commit_report
27
33
  collector.to_h.reduce "" do |details, (commit, analyzers)|
28
34
  details + Commit.new(commit: commit, analyzers: analyzers).to_s
29
35
  end
30
36
  end
31
37
 
32
- def branch_report
33
- return "" unless collector.issues?
34
-
35
- "\n\n#{commit_report}".chomp "\n"
36
- end
37
-
38
38
  def commit_total
39
39
  %(#{"commit".pluralize count: collector.total_commits} inspected)
40
40
  end
41
41
 
42
+ def issue_totals
43
+ if collector.issues?
44
+ "#{issue_total} detected (#{warning_total}, #{error_total})"
45
+ else
46
+ colorizer.green("0 issues") + " detected"
47
+ end
48
+ end
49
+
42
50
  def issue_total
43
51
  color = collector.errors? ? :red : :yellow
44
52
  colorizer.public_send color, "issue".pluralize(count: collector.total_issues)
@@ -53,14 +61,6 @@ module Git
53
61
  color = collector.errors? ? :red : :green
54
62
  colorizer.public_send color, "error".pluralize(count: collector.total_errors)
55
63
  end
56
-
57
- def issue_totals
58
- if collector.issues?
59
- "#{issue_total} detected (#{warning_total}, #{error_total})"
60
- else
61
- colorizer.green("0 issues") + " detected"
62
- end
63
- end
64
64
  end
65
65
  end
66
66
  end
@@ -3,19 +3,20 @@
3
3
  module Git
4
4
  module Lint
5
5
  class Runner
6
- def initialize configuration:, collector: Collector.new
6
+ def initialize configuration:, branch: Branches::Feature.new, collector: Collector.new
7
7
  @configuration = configuration
8
+ @branch = branch
8
9
  @collector = collector
9
10
  end
10
11
 
11
- def call commits: Branches::Feature.new.commits
12
- Array(commits).map { |commit| check commit }
12
+ def call commits: branch.commits
13
+ commits.map { |commit| check commit }
13
14
  collector
14
15
  end
15
16
 
16
17
  private
17
18
 
18
- attr_reader :configuration, :collector
19
+ attr_reader :configuration, :branch, :collector
19
20
 
20
21
  def check commit
21
22
  configuration.map { |id, settings| load_analyzer id, commit, settings }
@@ -4,7 +4,7 @@ module Git
4
4
  module Lint
5
5
  module Validators
6
6
  class Capitalization
7
- DEFAULT_PATTERN = /\A[[:upper:]].*\Z/.freeze
7
+ DEFAULT_PATTERN = /\A[[:upper:]].*\Z/
8
8
 
9
9
  def initialize text, delimiter: Name::DEFAULT_DELIMITER, pattern: DEFAULT_PATTERN
10
10
  @text = String text
@@ -4,7 +4,7 @@ module Git
4
4
  module Lint
5
5
  module Validators
6
6
  class Name
7
- DEFAULT_DELIMITER = /\s{1}/.freeze
7
+ DEFAULT_DELIMITER = /\s{1}/
8
8
  DEFAULT_MINIMUM = 2
9
9
 
10
10
  def initialize text, delimiter: DEFAULT_DELIMITER, minimum: DEFAULT_MINIMUM
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-lint
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -28,8 +28,22 @@ cert_chain:
28
28
  2XV8FRa7/JimI07sPLC13eLY3xd/aYTi85Z782KIA4j0G8XEEWAX0ouBhlXPocZv
29
29
  QWc=
30
30
  -----END CERTIFICATE-----
31
- date: 2020-12-13 00:00:00.000000000 Z
31
+ date: 2020-12-30 00:00:00.000000000 Z
32
32
  dependencies:
33
+ - !ruby/object:Gem::Dependency
34
+ name: git_plus
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '0.1'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '0.1'
33
47
  - !ruby/object:Gem::Dependency
34
48
  name: pastel
35
49
  requirement: !ruby/object:Gem::Requirement
@@ -50,28 +64,28 @@ dependencies:
50
64
  requirements:
51
65
  - - "~>"
52
66
  - !ruby/object:Gem::Version
53
- version: '7.16'
67
+ version: '8.0'
54
68
  type: :runtime
55
69
  prerelease: false
56
70
  version_requirements: !ruby/object:Gem::Requirement
57
71
  requirements:
58
72
  - - "~>"
59
73
  - !ruby/object:Gem::Version
60
- version: '7.16'
74
+ version: '8.0'
61
75
  - !ruby/object:Gem::Dependency
62
76
  name: runcom
63
77
  requirement: !ruby/object:Gem::Requirement
64
78
  requirements:
65
79
  - - "~>"
66
80
  - !ruby/object:Gem::Version
67
- version: '6.4'
81
+ version: '7.0'
68
82
  type: :runtime
69
83
  prerelease: false
70
84
  version_requirements: !ruby/object:Gem::Requirement
71
85
  requirements:
72
86
  - - "~>"
73
87
  - !ruby/object:Gem::Version
74
- version: '6.4'
88
+ version: '7.0'
75
89
  - !ruby/object:Gem::Dependency
76
90
  name: thor
77
91
  requirement: !ruby/object:Gem::Requirement
@@ -99,7 +113,6 @@ files:
99
113
  - LICENSE.adoc
100
114
  - README.adoc
101
115
  - bin/git-lint
102
- - lib/git/kit/repo.rb
103
116
  - lib/git/lint.rb
104
117
  - lib/git/lint/analyzers/abstract.rb
105
118
  - lib/git/lint/analyzers/commit_author_capitalization.rb
@@ -131,8 +144,6 @@ files:
131
144
  - lib/git/lint/branches/feature.rb
132
145
  - lib/git/lint/cli.rb
133
146
  - lib/git/lint/collector.rb
134
- - lib/git/lint/commits/saved.rb
135
- - lib/git/lint/commits/unsaved.rb
136
147
  - lib/git/lint/errors/base.rb
137
148
  - lib/git/lint/errors/severity.rb
138
149
  - lib/git/lint/errors/sha.rb
@@ -168,14 +179,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
168
179
  requirements:
169
180
  - - "~>"
170
181
  - !ruby/object:Gem::Version
171
- version: '2.7'
182
+ version: '3.0'
172
183
  required_rubygems_version: !ruby/object:Gem::Requirement
173
184
  requirements:
174
185
  - - ">="
175
186
  - !ruby/object:Gem::Version
176
187
  version: '0'
177
188
  requirements: []
178
- rubygems_version: 3.2.0
189
+ rubygems_version: 3.2.3
179
190
  signing_key:
180
191
  specification_version: 4
181
192
  summary: A command line interface for linting Git commits.
metadata.gz.sig CHANGED
@@ -1,2 +1,2 @@
1
- be�����G`,�j��w
2
- ���<G�<DH��Zb��H ���`�.�h���8����&m�i LT�}~��S
1
+ 'p,"��/-�^'��,��q������If(-���_�CG ��Mل�r�j����-.
2
+ �Q9�d�v��Sc;�0Q<DH������n )`#��K��lN����բ��'8LRd[P����먄�����֒$���؄���' Wd*����W'�N����n�
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Git
4
- module Kit
5
- class Repo
6
- def initialize shell: Open3
7
- @shell = shell
8
- end
9
-
10
- def exist?
11
- shell.capture2e("git rev-parse --git-dir > /dev/null 2>&1")
12
- .then { |result, status| result && status.success? }
13
- end
14
-
15
- def branch_name
16
- shell.capture2e("git rev-parse --abbrev-ref HEAD | tr -d '\n'")
17
- .then { |result, _status| result }
18
- end
19
-
20
- def shas start: "master", finish: branch_name
21
- shell.capture2e(%(git log --pretty=format:"%H" #{start}..#{finish}))
22
- .then { |result, _status| result.split "\n" }
23
- end
24
-
25
- private
26
-
27
- attr_reader :shell
28
- end
29
- end
30
- end
@@ -1,104 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "open3"
4
-
5
- module Git
6
- module Lint
7
- module Commits
8
- # Represents an existing commit.
9
- # :reek:TooManyMethods
10
- class Saved
11
- using Refinements::Strings
12
-
13
- FORMATS = {
14
- sha: "%H",
15
- author_name: "%an",
16
- author_email: "%ae",
17
- author_date_relative: "%ar",
18
- subject: "%s",
19
- body: "%b",
20
- raw_body: "%B",
21
- trailers: "%(trailers)"
22
- }.freeze
23
-
24
- def self.pattern
25
- FORMATS.reduce("") { |pattern, (key, value)| pattern + "<#{key}>#{value}</#{key}>%n" }
26
- end
27
-
28
- def initialize sha:, shell: Open3
29
- data, status = shell.capture2e show_command(sha)
30
- fail Errors::SHA, sha unless status.success?
31
-
32
- @data = data.scrub "?"
33
- end
34
-
35
- def == other
36
- other.is_a?(self.class) && sha == other.sha
37
- end
38
- alias eql? ==
39
-
40
- def <=> other
41
- sha <=> other.sha
42
- end
43
-
44
- def hash
45
- sha.hash
46
- end
47
-
48
- def body_lines
49
- body_without_trailing_spaces
50
- end
51
-
52
- def body_paragraphs
53
- body_without_trailers.split("\n\n").map(&:chomp).reject { |line| line.start_with? "#" }
54
- end
55
-
56
- def trailer_lines
57
- trailers.split "\n"
58
- end
59
-
60
- def trailer_index
61
- body.split("\n").index trailer_lines.first
62
- end
63
-
64
- def fixup?
65
- subject.fixup?
66
- end
67
-
68
- def squash?
69
- subject.squash?
70
- end
71
-
72
- private
73
-
74
- attr_reader :data
75
-
76
- def show_command sha
77
- %(git show --stat --pretty=format:"#{self.class.pattern}" #{sha})
78
- end
79
-
80
- def body_without_trailing_spaces
81
- body_without_comments.reverse.drop_while(&:empty?).reverse
82
- end
83
-
84
- def body_without_comments
85
- body_without_trailers.split("\n").reject { |line| line.start_with? "#" }
86
- end
87
-
88
- def body_without_trailers
89
- body.sub trailers, ""
90
- end
91
-
92
- def method_missing name, *arguments, &block
93
- return super unless respond_to_missing? name
94
-
95
- String data[%r(<#{name}>(?<content>.*?)</#{name}>)m, :content]
96
- end
97
-
98
- def respond_to_missing? name, include_private = false
99
- FORMATS.key?(name.to_sym) || super
100
- end
101
- end
102
- end
103
- end
104
- end
@@ -1,120 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "pathname"
4
- require "open3"
5
- require "securerandom"
6
-
7
- module Git
8
- module Lint
9
- module Commits
10
- # Represents a partially formed, unsaved commit.
11
- # :reek:TooManyMethods
12
- class Unsaved
13
- using Refinements::Strings
14
-
15
- SUBJECT_LINE = 1
16
- SCISSOR_PATTERN = /\#\s-+\s>8\s-+\n.+/m.freeze
17
-
18
- attr_reader :sha, :raw_body
19
-
20
- def initialize path:, sha: SecureRandom.hex(20), shell: Open3
21
- fail Errors::Base, %(Invalid commit message path: "#{path}".) unless File.exist? path
22
-
23
- @path = Pathname path
24
- @sha = sha
25
- @shell = shell
26
- @raw_body = File.read(path).scrub "?"
27
- end
28
-
29
- def author_name
30
- shell.capture2e("git config --get user.name").then { |result, _status| result.chomp }
31
- end
32
-
33
- def author_email
34
- shell.capture2e("git config --get user.email").then { |result, _status| result.chomp }
35
- end
36
-
37
- def author_date_relative
38
- "0 seconds ago"
39
- end
40
-
41
- def subject
42
- String raw_body.split("\n").first
43
- end
44
-
45
- # :reek:FeatureEnvy
46
- def body
47
- raw_body.sub(SCISSOR_PATTERN, "").split("\n").drop(SUBJECT_LINE).then do |lines|
48
- computed_body = lines.join "\n"
49
- lines.empty? ? computed_body : "#{computed_body}\n"
50
- end
51
- end
52
-
53
- def body_lines
54
- body_without_trailing_spaces
55
- end
56
-
57
- # :reek:FeatureEnvy
58
- def body_paragraphs
59
- body_without_trailers.split("\n\n")
60
- .map { |line| line.delete_prefix "\n" }
61
- .map(&:chomp)
62
- .reject { |line| line.start_with? "#" }
63
- end
64
-
65
- def trailers
66
- trailers, status = shell.capture2e %(git interpret-trailers --only-trailers "#{path}")
67
-
68
- return "" unless status.success?
69
-
70
- trailers
71
- end
72
-
73
- def trailer_lines
74
- trailers.split "\n"
75
- end
76
-
77
- def trailer_index
78
- body.split("\n").index trailer_lines.first
79
- end
80
-
81
- def == other
82
- other.is_a?(self.class) && raw_body == other.raw_body
83
- end
84
- alias eql? ==
85
-
86
- def <=> other
87
- raw_body <=> other.raw_body
88
- end
89
-
90
- def hash
91
- raw_body.hash
92
- end
93
-
94
- def fixup?
95
- subject.fixup?
96
- end
97
-
98
- def squash?
99
- subject.squash?
100
- end
101
-
102
- private
103
-
104
- attr_reader :path, :shell
105
-
106
- def body_without_trailing_spaces
107
- body_without_comments.reverse.drop_while(&:empty?).reverse
108
- end
109
-
110
- def body_without_comments
111
- body_without_trailers.split("\n").reject { |line| line.start_with? "#" }
112
- end
113
-
114
- def body_without_trailers
115
- body.sub trailers, ""
116
- end
117
- end
118
- end
119
- end
120
- end