git-lint 3.3.2 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/git-lint.gemspec +4 -2
- data/lib/git/lint/analyzer.rb +6 -4
- data/lib/git/lint/analyzers/abstract.rb +6 -4
- data/lib/git/lint/analyzers/commit_author_capitalization.rb +2 -2
- data/lib/git/lint/analyzers/commit_author_email.rb +2 -2
- data/lib/git/lint/analyzers/commit_author_name.rb +2 -2
- data/lib/git/lint/analyzers/commit_subject_prefix.rb +1 -1
- data/lib/git/lint/analyzers/commit_trailer_collaborator_capitalization.rb +5 -2
- data/lib/git/lint/analyzers/commit_trailer_collaborator_duplication.rb +2 -2
- data/lib/git/lint/analyzers/commit_trailer_collaborator_email.rb +5 -3
- data/lib/git/lint/analyzers/commit_trailer_collaborator_key.rb +2 -2
- data/lib/git/lint/analyzers/commit_trailer_collaborator_name.rb +5 -3
- data/lib/git/lint/cli/actions/analyze/branch.rb +5 -9
- data/lib/git/lint/cli/actions/analyze/commit.rb +5 -7
- data/lib/git/lint/cli/actions/config.rb +5 -7
- data/lib/git/lint/cli/actions/container.rb +25 -0
- data/lib/git/lint/cli/actions/hook.rb +5 -9
- data/lib/git/lint/cli/actions/import.rb +13 -0
- data/lib/git/lint/cli/parser.rb +8 -5
- data/lib/git/lint/cli/parsers/core.rb +5 -5
- data/lib/git/lint/cli/shell.rb +17 -30
- data/lib/git/lint/commits/loader.rb +13 -22
- data/lib/git/lint/commits/systems/circle_ci.rb +1 -7
- data/lib/git/lint/commits/systems/container.rb +25 -0
- data/lib/git/lint/commits/systems/git_hub_action.rb +1 -7
- data/lib/git/lint/commits/systems/import.rb +13 -0
- data/lib/git/lint/commits/systems/local.rb +1 -7
- data/lib/git/lint/commits/systems/netlify_ci.rb +3 -13
- data/lib/git/lint/container.rb +4 -24
- data/lib/git/lint/import.rb +9 -0
- data.tar.gz.sig +0 -0
- metadata +48 -16
- metadata.gz.sig +0 -0
- data/lib/git/lint/commits/container.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8db52556e39c3841f3c14399aba51d98569a2be8507ddb491db2141f1a5c69ef
|
4
|
+
data.tar.gz: 88f6abbbc71e0359ce9c4478cd18b087cc84d6845cfb3aea076ffbb2aeffec69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5114c6e63c3f59b6c7643e8eb201f6119ed3fd5cfcdfa518f3fe90287e34f2b27b74d0f89f4890f560e58bf1244b89f94f64f14ce8c7a2371d0dc1abce60bef2
|
7
|
+
data.tar.gz: fa5b831b4f0f938dd16d579647813ff49baabf73d960c70a5dcaff74b6785c9111a2513428cf00cc18bf00227975639650d5152d7e87731493415c815e36448f
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/git-lint.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "git-lint"
|
5
|
-
spec.version = "
|
5
|
+
spec.version = "4.0.0"
|
6
6
|
spec.authors = ["Brooke Kuhlmann"]
|
7
7
|
spec.email = ["brooke@alchemists.io"]
|
8
8
|
spec.homepage = "https://www.alchemists.io/projects/git-lint"
|
@@ -22,7 +22,9 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.cert_chain = [Gem.default_cert_path]
|
23
23
|
|
24
24
|
spec.required_ruby_version = "~> 3.1"
|
25
|
-
spec.add_dependency "
|
25
|
+
spec.add_dependency "auto_injector", "~> 0.4"
|
26
|
+
spec.add_dependency "cogger", "~> 0.0"
|
27
|
+
spec.add_dependency "dry-container", "~> 0.9"
|
26
28
|
spec.add_dependency "git_plus", "~> 1.1"
|
27
29
|
spec.add_dependency "pastel", "~> 0.8"
|
28
30
|
spec.add_dependency "refinements", "~> 9.2"
|
data/lib/git/lint/analyzer.rb
CHANGED
@@ -4,6 +4,8 @@ module Git
|
|
4
4
|
module Lint
|
5
5
|
# Runs all analyzers.
|
6
6
|
class Analyzer
|
7
|
+
include Import[:configuration]
|
8
|
+
|
7
9
|
ANALYZERS = [
|
8
10
|
Analyzers::CommitAuthorCapitalization,
|
9
11
|
Analyzers::CommitAuthorEmail,
|
@@ -32,11 +34,11 @@ module Git
|
|
32
34
|
def initialize analyzers: ANALYZERS,
|
33
35
|
collector: Collector.new,
|
34
36
|
reporter: Reporters::Branch,
|
35
|
-
|
37
|
+
**dependencies
|
38
|
+
super(**dependencies)
|
36
39
|
@analyzers = analyzers
|
37
40
|
@collector = collector
|
38
41
|
@reporter = reporter
|
39
|
-
@container = container
|
40
42
|
end
|
41
43
|
# rubocop:enable Metrics/ParameterLists
|
42
44
|
|
@@ -48,7 +50,7 @@ module Git
|
|
48
50
|
|
49
51
|
private
|
50
52
|
|
51
|
-
attr_reader :analyzers, :collector, :reporter
|
53
|
+
attr_reader :analyzers, :collector, :reporter
|
52
54
|
|
53
55
|
def process commits
|
54
56
|
collector.clear
|
@@ -70,7 +72,7 @@ module Git
|
|
70
72
|
end
|
71
73
|
end
|
72
74
|
|
73
|
-
def settings =
|
75
|
+
def settings = configuration.analyzers
|
74
76
|
end
|
75
77
|
end
|
76
78
|
end
|
@@ -7,6 +7,8 @@ module Git
|
|
7
7
|
module Analyzers
|
8
8
|
# An abstract class which provides basic functionality from which all analyzers inherit from.
|
9
9
|
class Abstract
|
10
|
+
include Import[:configuration, :environment]
|
11
|
+
|
10
12
|
using ::Refinements::Strings
|
11
13
|
|
12
14
|
LEVELS = %i[warn error].freeze
|
@@ -20,9 +22,9 @@ module Git
|
|
20
22
|
|
21
23
|
attr_reader :commit
|
22
24
|
|
23
|
-
def initialize commit,
|
25
|
+
def initialize commit, **dependencies
|
26
|
+
super(**dependencies)
|
24
27
|
@commit = commit
|
25
|
-
@container = container
|
26
28
|
@filter_list = load_filter_list
|
27
29
|
end
|
28
30
|
|
@@ -50,7 +52,7 @@ module Git
|
|
50
52
|
|
51
53
|
protected
|
52
54
|
|
53
|
-
attr_reader :
|
55
|
+
attr_reader :filter_list
|
54
56
|
|
55
57
|
def load_filter_list = []
|
56
58
|
|
@@ -74,7 +76,7 @@ module Git
|
|
74
76
|
fail NotImplementedError, "The `.#{__method__}` method must be implemented."
|
75
77
|
end
|
76
78
|
|
77
|
-
def settings =
|
79
|
+
def settings = configuration.find_setting(self.class.id)
|
78
80
|
end
|
79
81
|
end
|
80
82
|
end
|
@@ -5,8 +5,8 @@ module Git
|
|
5
5
|
module Analyzers
|
6
6
|
# Analyzes author for proper capitalization of author name.
|
7
7
|
class CommitAuthorCapitalization < Abstract
|
8
|
-
def initialize commit, validator: Validators::Capitalization
|
9
|
-
super commit
|
8
|
+
def initialize commit, validator: Validators::Capitalization, **dependencies
|
9
|
+
super commit, **dependencies
|
10
10
|
@validator = validator
|
11
11
|
end
|
12
12
|
|
@@ -5,8 +5,8 @@ module Git
|
|
5
5
|
module Analyzers
|
6
6
|
# Analyzes author email address for proper format.
|
7
7
|
class CommitAuthorEmail < Abstract
|
8
|
-
def initialize commit, validator: Validators::Email
|
9
|
-
super commit
|
8
|
+
def initialize commit, validator: Validators::Email, **dependencies
|
9
|
+
super commit, **dependencies
|
10
10
|
@validator = validator
|
11
11
|
end
|
12
12
|
|
@@ -5,8 +5,8 @@ module Git
|
|
5
5
|
module Analyzers
|
6
6
|
# Analyzes author name for minimum parts of name.
|
7
7
|
class CommitAuthorName < Abstract
|
8
|
-
def initialize commit, validator: Validators::Name
|
9
|
-
super commit
|
8
|
+
def initialize commit, validator: Validators::Name, **dependencies
|
9
|
+
super commit, **dependencies
|
10
10
|
@validator = validator
|
11
11
|
end
|
12
12
|
|
@@ -5,13 +5,16 @@ module Git
|
|
5
5
|
module Analyzers
|
6
6
|
# Analyzes commit trailer collaborator name capitalization.
|
7
7
|
class CommitTrailerCollaboratorCapitalization < Abstract
|
8
|
+
# rubocop:disable Metrics/ParameterLists
|
8
9
|
def initialize commit,
|
9
10
|
parser: Parsers::Trailers::Collaborator,
|
10
|
-
validator: Validators::Capitalization
|
11
|
-
|
11
|
+
validator: Validators::Capitalization,
|
12
|
+
**dependencies
|
13
|
+
super commit, **dependencies
|
12
14
|
@parser = parser
|
13
15
|
@validator = validator
|
14
16
|
end
|
17
|
+
# rubocop:enable Metrics/ParameterLists
|
15
18
|
|
16
19
|
def valid? = affected_commit_trailers.empty?
|
17
20
|
|
@@ -5,8 +5,8 @@ module Git
|
|
5
5
|
module Analyzers
|
6
6
|
# Analyzes commit trailer collaborator duplication.
|
7
7
|
class CommitTrailerCollaboratorDuplication < Abstract
|
8
|
-
def initialize commit, parser: Parsers::Trailers::Collaborator
|
9
|
-
super commit
|
8
|
+
def initialize commit, parser: Parsers::Trailers::Collaborator, **dependencies
|
9
|
+
super commit, **dependencies
|
10
10
|
@parser = parser
|
11
11
|
@tally = build_tally
|
12
12
|
end
|
@@ -5,14 +5,16 @@ module Git
|
|
5
5
|
module Analyzers
|
6
6
|
# Analyzes commit trailer collaborator email address format.
|
7
7
|
class CommitTrailerCollaboratorEmail < Abstract
|
8
|
+
# rubocop:disable Metrics/ParameterLists
|
8
9
|
def initialize commit,
|
9
10
|
parser: Parsers::Trailers::Collaborator,
|
10
|
-
validator: Validators::Email
|
11
|
-
|
12
|
-
super commit
|
11
|
+
validator: Validators::Email,
|
12
|
+
**dependencies
|
13
|
+
super commit, **dependencies
|
13
14
|
@parser = parser
|
14
15
|
@validator = validator
|
15
16
|
end
|
17
|
+
# rubocop:enable Metrics/ParameterLists
|
16
18
|
|
17
19
|
def valid? = affected_commit_trailers.empty?
|
18
20
|
|
@@ -5,8 +5,8 @@ module Git
|
|
5
5
|
module Analyzers
|
6
6
|
# Analyzes commit trailer collaborator key usage.
|
7
7
|
class CommitTrailerCollaboratorKey < Abstract
|
8
|
-
def initialize commit, parser: Parsers::Trailers::Collaborator
|
9
|
-
super commit
|
8
|
+
def initialize commit, parser: Parsers::Trailers::Collaborator, **dependencies
|
9
|
+
super commit, **dependencies
|
10
10
|
@parser = parser
|
11
11
|
end
|
12
12
|
|
@@ -5,14 +5,16 @@ module Git
|
|
5
5
|
module Analyzers
|
6
6
|
# Analyzes commit trailer collaborator name construction.
|
7
7
|
class CommitTrailerCollaboratorName < Abstract
|
8
|
+
# rubocop:disable Metrics/ParameterLists
|
8
9
|
def initialize commit,
|
9
10
|
parser: Parsers::Trailers::Collaborator,
|
10
|
-
validator: Validators::Name
|
11
|
-
|
12
|
-
super commit
|
11
|
+
validator: Validators::Name,
|
12
|
+
**dependencies
|
13
|
+
super commit, **dependencies
|
13
14
|
@parser = parser
|
14
15
|
@validator = validator
|
15
16
|
end
|
17
|
+
# rubocop:enable Metrics/ParameterLists
|
16
18
|
|
17
19
|
def valid? = affected_commit_trailers.empty?
|
18
20
|
|
@@ -7,9 +7,11 @@ module Git
|
|
7
7
|
module Analyze
|
8
8
|
# Handles analyze action for branch.
|
9
9
|
class Branch
|
10
|
-
|
10
|
+
include Git::Lint::Import[:repository, :kernel, :logger]
|
11
|
+
|
12
|
+
def initialize analyzer: Analyzer.new, **dependencies
|
13
|
+
super(**dependencies)
|
11
14
|
@analyzer = analyzer
|
12
|
-
@container = container
|
13
15
|
end
|
14
16
|
|
15
17
|
def call
|
@@ -21,7 +23,7 @@ module Git
|
|
21
23
|
|
22
24
|
private
|
23
25
|
|
24
|
-
attr_reader :analyzer
|
26
|
+
attr_reader :analyzer
|
25
27
|
|
26
28
|
def parse
|
27
29
|
analyzer.call do |collector, reporter|
|
@@ -29,12 +31,6 @@ module Git
|
|
29
31
|
kernel.abort if collector.errors?
|
30
32
|
end
|
31
33
|
end
|
32
|
-
|
33
|
-
def repository = container[__method__]
|
34
|
-
|
35
|
-
def kernel = container[__method__]
|
36
|
-
|
37
|
-
def logger = container[__method__]
|
38
34
|
end
|
39
35
|
end
|
40
36
|
end
|
@@ -7,12 +7,14 @@ module Git
|
|
7
7
|
module Analyze
|
8
8
|
# Handles analyze action for commit(s) by SHA.
|
9
9
|
class Commit
|
10
|
+
include Git::Lint::Import[:kernel, :logger]
|
11
|
+
|
10
12
|
def initialize analyzer: Analyzer.new,
|
11
13
|
parser: GitPlus::Parsers::Commits::Saved::History.with_show,
|
12
|
-
|
14
|
+
**dependencies
|
15
|
+
super(**dependencies)
|
13
16
|
@analyzer = analyzer
|
14
17
|
@parser = parser
|
15
|
-
@container = container
|
16
18
|
end
|
17
19
|
|
18
20
|
def call sha = nil
|
@@ -24,7 +26,7 @@ module Git
|
|
24
26
|
|
25
27
|
private
|
26
28
|
|
27
|
-
attr_reader :analyzer, :parser
|
29
|
+
attr_reader :analyzer, :parser
|
28
30
|
|
29
31
|
def process sha
|
30
32
|
analyzer.call commits: parser.call(*sha) do |collector, reporter|
|
@@ -32,10 +34,6 @@ module Git
|
|
32
34
|
kernel.abort if collector.errors?
|
33
35
|
end
|
34
36
|
end
|
35
|
-
|
36
|
-
def kernel = container[__method__]
|
37
|
-
|
38
|
-
def logger = container[__method__]
|
39
37
|
end
|
40
38
|
end
|
41
39
|
end
|
@@ -6,9 +6,11 @@ module Git
|
|
6
6
|
module Actions
|
7
7
|
# Handles gem configuration action.
|
8
8
|
class Config
|
9
|
-
|
9
|
+
include Git::Lint::Import[:kernel, :logger]
|
10
|
+
|
11
|
+
def initialize configuration: Configuration::Loader::CLIENT, **dependencies
|
12
|
+
super(**dependencies)
|
10
13
|
@configuration = configuration
|
11
|
-
@container = container
|
12
14
|
end
|
13
15
|
|
14
16
|
def call action
|
@@ -21,15 +23,11 @@ module Git
|
|
21
23
|
|
22
24
|
private
|
23
25
|
|
24
|
-
attr_reader :configuration
|
26
|
+
attr_reader :configuration
|
25
27
|
|
26
28
|
def edit = kernel.system("$EDITOR #{configuration.current}")
|
27
29
|
|
28
30
|
def view = kernel.system("cat #{configuration.current}")
|
29
|
-
|
30
|
-
def kernel = container[__method__]
|
31
|
-
|
32
|
-
def logger = container[__method__]
|
33
31
|
end
|
34
32
|
end
|
35
33
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "dry/container"
|
4
|
+
|
5
|
+
module Git
|
6
|
+
module Lint
|
7
|
+
module CLI
|
8
|
+
module Actions
|
9
|
+
# Provides a single container with application and action specific dependencies.
|
10
|
+
module Container
|
11
|
+
extend Dry::Container::Mixin
|
12
|
+
|
13
|
+
config.registry = ->(container, key, value, _options) { container[key.to_s] = value }
|
14
|
+
|
15
|
+
merge Git::Lint::Container
|
16
|
+
|
17
|
+
register(:analyze_branch) { Analyze::Branch.new }
|
18
|
+
register(:analyze_commit) { Analyze::Commit.new }
|
19
|
+
register(:config) { Config.new }
|
20
|
+
register(:hook) { Hook.new }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -6,9 +6,11 @@ module Git
|
|
6
6
|
module Actions
|
7
7
|
# Handles unsaved Git commit action.
|
8
8
|
class Hook
|
9
|
-
|
9
|
+
include Git::Lint::Import[:repository, :kernel, :logger]
|
10
|
+
|
11
|
+
def initialize analyzer: Analyzer.new, **dependencies
|
12
|
+
super(**dependencies)
|
10
13
|
@analyzer = analyzer
|
11
|
-
@container = container
|
12
14
|
end
|
13
15
|
|
14
16
|
def call path
|
@@ -20,13 +22,7 @@ module Git
|
|
20
22
|
|
21
23
|
private
|
22
24
|
|
23
|
-
attr_reader :analyzer
|
24
|
-
|
25
|
-
def repository = container[__method__]
|
26
|
-
|
27
|
-
def kernel = container[__method__]
|
28
|
-
|
29
|
-
def logger = container[__method__]
|
25
|
+
attr_reader :analyzer
|
30
26
|
end
|
31
27
|
end
|
32
28
|
end
|
data/lib/git/lint/cli/parser.rb
CHANGED
@@ -7,26 +7,29 @@ module Git
|
|
7
7
|
module CLI
|
8
8
|
# Assembles and parses all Command Line Interface (CLI) options.
|
9
9
|
class Parser
|
10
|
+
include Import[:configuration]
|
11
|
+
|
10
12
|
CLIENT = OptionParser.new nil, 40, " "
|
11
13
|
SECTIONS = [Parsers::Core, Parsers::Analyze].freeze # Order matters.
|
12
14
|
|
13
|
-
def initialize sections: SECTIONS, client: CLIENT,
|
15
|
+
def initialize sections: SECTIONS, client: CLIENT, **dependencies
|
16
|
+
super(**dependencies)
|
14
17
|
@sections = sections
|
15
18
|
@client = client
|
16
|
-
@
|
19
|
+
@configuration_duplicate = configuration.dup
|
17
20
|
end
|
18
21
|
|
19
22
|
def call arguments = []
|
20
|
-
sections.each { |section| section.call
|
23
|
+
sections.each { |section| section.call configuration_duplicate, client: }
|
21
24
|
client.parse arguments
|
22
|
-
|
25
|
+
configuration_duplicate.freeze
|
23
26
|
end
|
24
27
|
|
25
28
|
def to_s = client.to_s
|
26
29
|
|
27
30
|
private
|
28
31
|
|
29
|
-
attr_reader :sections, :client, :
|
32
|
+
attr_reader :sections, :client, :configuration_duplicate
|
30
33
|
end
|
31
34
|
end
|
32
35
|
end
|
@@ -8,16 +8,18 @@ module Git
|
|
8
8
|
module Parsers
|
9
9
|
# Handles parsing of Command Line Interface (CLI) core options.
|
10
10
|
class Core
|
11
|
+
include Import[:specification]
|
12
|
+
|
11
13
|
using ::Refinements::Structs
|
12
14
|
|
13
15
|
def self.call(...) = new(...).call
|
14
16
|
|
15
17
|
def initialize configuration = Container[:configuration],
|
16
18
|
client: Parser::CLIENT,
|
17
|
-
|
19
|
+
**dependencies
|
20
|
+
super(**dependencies)
|
18
21
|
@configuration = configuration
|
19
22
|
@client = client
|
20
|
-
@container = container
|
21
23
|
end
|
22
24
|
|
23
25
|
def call arguments = []
|
@@ -30,7 +32,7 @@ module Git
|
|
30
32
|
|
31
33
|
private
|
32
34
|
|
33
|
-
attr_reader :configuration, :client
|
35
|
+
attr_reader :configuration, :client
|
34
36
|
|
35
37
|
def collate = private_methods.sort.grep(/add_/).each { |method| __send__ method }
|
36
38
|
|
@@ -68,8 +70,6 @@ module Git
|
|
68
70
|
configuration.merge! action_help: true
|
69
71
|
end
|
70
72
|
end
|
71
|
-
|
72
|
-
def specification = container[__method__]
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
data/lib/git/lint/cli/shell.rb
CHANGED
@@ -5,17 +5,18 @@ module Git
|
|
5
5
|
module CLI
|
6
6
|
# The main Command Line Interface (CLI) object.
|
7
7
|
class Shell
|
8
|
-
|
9
|
-
analyze_branch
|
10
|
-
analyze_commit
|
11
|
-
config
|
12
|
-
hook
|
13
|
-
|
14
|
-
|
15
|
-
|
8
|
+
include Actions::Import[
|
9
|
+
:analyze_branch,
|
10
|
+
:analyze_commit,
|
11
|
+
:config,
|
12
|
+
:hook,
|
13
|
+
:specification,
|
14
|
+
:logger
|
15
|
+
]
|
16
|
+
|
17
|
+
def initialize parser: Parser.new, **dependencies
|
18
|
+
super(**dependencies)
|
16
19
|
@parser = parser
|
17
|
-
@actions = actions
|
18
|
-
@container = container
|
19
20
|
end
|
20
21
|
|
21
22
|
def call arguments = []
|
@@ -26,32 +27,18 @@ module Git
|
|
26
27
|
|
27
28
|
private
|
28
29
|
|
29
|
-
attr_reader :parser
|
30
|
+
attr_reader :parser
|
30
31
|
|
31
32
|
def perform configuration
|
32
33
|
case configuration
|
33
|
-
in action_analyze: true, analyze_sha: nil then analyze_branch
|
34
|
-
in action_analyze: true, analyze_sha: String => sha then analyze_commit sha
|
35
|
-
in action_config: Symbol => action then config action
|
36
|
-
in action_hook: Pathname => path then hook path
|
34
|
+
in action_analyze: true, analyze_sha: nil then analyze_branch.call
|
35
|
+
in action_analyze: true, analyze_sha: String => sha then analyze_commit.call sha
|
36
|
+
in action_config: Symbol => action then config.call action
|
37
|
+
in action_hook: Pathname => path then hook.call path
|
37
38
|
in action_version: true then logger.info { specification.labeled_version }
|
38
|
-
else
|
39
|
+
else logger.any { parser.to_s }
|
39
40
|
end
|
40
41
|
end
|
41
|
-
|
42
|
-
def analyze_branch = actions.fetch(__method__).call
|
43
|
-
|
44
|
-
def analyze_commit(sha) = actions.fetch(__method__).call(sha)
|
45
|
-
|
46
|
-
def config(action) = actions.fetch(__method__).call(action)
|
47
|
-
|
48
|
-
def hook(path) = actions.fetch(__method__).call(path)
|
49
|
-
|
50
|
-
def usage = logger.unknown { parser.to_s }
|
51
|
-
|
52
|
-
def specification = container[__method__]
|
53
|
-
|
54
|
-
def logger = container[__method__]
|
55
42
|
end
|
56
43
|
end
|
57
44
|
end
|
@@ -7,19 +7,16 @@ module Git
|
|
7
7
|
module Commits
|
8
8
|
# Automatically detects and loads system.
|
9
9
|
class Loader
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
10
|
+
include Systems::Import[
|
11
|
+
:circle_ci,
|
12
|
+
:git_hub_action,
|
13
|
+
:netlify_ci,
|
14
|
+
:local,
|
15
|
+
:repository,
|
16
|
+
:environment
|
17
|
+
]
|
18
18
|
|
19
|
-
|
20
|
-
@systems = systems
|
21
|
-
@container = container
|
22
|
-
end
|
19
|
+
using ::Refinements::Strings
|
23
20
|
|
24
21
|
def call
|
25
22
|
message = "Invalid repository. Are you within a Git repository?"
|
@@ -30,21 +27,15 @@ module Git
|
|
30
27
|
|
31
28
|
private
|
32
29
|
|
33
|
-
attr_reader :systems, :container
|
34
|
-
|
35
30
|
def load_system
|
36
|
-
if key? "CIRCLECI" then
|
37
|
-
elsif key? "GITHUB_ACTIONS" then
|
38
|
-
elsif key? "NETLIFY" then
|
39
|
-
else
|
31
|
+
if key? "CIRCLECI" then circle_ci
|
32
|
+
elsif key? "GITHUB_ACTIONS" then git_hub_action
|
33
|
+
elsif key? "NETLIFY" then netlify_ci
|
34
|
+
else local
|
40
35
|
end
|
41
36
|
end
|
42
37
|
|
43
38
|
def key?(key) = environment.fetch(key, "false").to_bool
|
44
|
-
|
45
|
-
def repository = container[__method__]
|
46
|
-
|
47
|
-
def environment = container[__method__]
|
48
39
|
end
|
49
40
|
end
|
50
41
|
end
|
@@ -6,19 +6,13 @@ module Git
|
|
6
6
|
module Systems
|
7
7
|
# Provides Circle CI build environment feature branch information.
|
8
8
|
class CircleCI
|
9
|
-
|
10
|
-
@container = container
|
11
|
-
end
|
9
|
+
include Git::Lint::Import[:repository]
|
12
10
|
|
13
11
|
def call = repository.commits("origin/#{repository.branch_default}..#{name}")
|
14
12
|
|
15
13
|
private
|
16
14
|
|
17
|
-
attr_reader :container
|
18
|
-
|
19
15
|
def name = "origin/#{repository.branch_name}"
|
20
|
-
|
21
|
-
def repository = container[__method__]
|
22
16
|
end
|
23
17
|
end
|
24
18
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "dry/container"
|
4
|
+
|
5
|
+
module Git
|
6
|
+
module Lint
|
7
|
+
module Commits
|
8
|
+
module Systems
|
9
|
+
# Provides a single container with application and system specific dependencies.
|
10
|
+
module Container
|
11
|
+
extend Dry::Container::Mixin
|
12
|
+
|
13
|
+
config.registry = ->(container, key, value, _options) { container[key.to_s] = value }
|
14
|
+
|
15
|
+
merge Git::Lint::Container
|
16
|
+
|
17
|
+
register(:circle_ci) { CircleCI.new }
|
18
|
+
register(:git_hub_action) { GitHubAction.new }
|
19
|
+
register(:netlify_ci) { NetlifyCI.new }
|
20
|
+
register(:local) { Local.new }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -6,19 +6,13 @@ module Git
|
|
6
6
|
module Systems
|
7
7
|
# Provides GitHub Action build environment feature branch information.
|
8
8
|
class GitHubAction
|
9
|
-
|
10
|
-
@container = container
|
11
|
-
end
|
9
|
+
include Git::Lint::Import[:repository]
|
12
10
|
|
13
11
|
def call = repository.commits("origin/#{repository.branch_default}..#{name}")
|
14
12
|
|
15
13
|
private
|
16
14
|
|
17
|
-
attr_reader :container
|
18
|
-
|
19
15
|
def name = "origin/#{repository.branch_name}"
|
20
|
-
|
21
|
-
def repository = container[__method__]
|
22
16
|
end
|
23
17
|
end
|
24
18
|
end
|
@@ -6,19 +6,13 @@ module Git
|
|
6
6
|
module Systems
|
7
7
|
# Provides local build environment feature branch information.
|
8
8
|
class Local
|
9
|
-
|
10
|
-
@container = container
|
11
|
-
end
|
9
|
+
include Git::Lint::Import[:repository]
|
12
10
|
|
13
11
|
def call = repository.commits("#{repository.branch_default}..#{name}")
|
14
12
|
|
15
13
|
private
|
16
14
|
|
17
|
-
attr_reader :container
|
18
|
-
|
19
15
|
def name = repository.branch_name
|
20
|
-
|
21
|
-
def repository = container[__method__]
|
22
16
|
end
|
23
17
|
end
|
24
18
|
end
|
@@ -8,27 +8,17 @@ module Git
|
|
8
8
|
module Systems
|
9
9
|
# Provides Netlify CI build environment feature branch information.
|
10
10
|
class NetlifyCI
|
11
|
-
|
12
|
-
@container = container
|
13
|
-
end
|
11
|
+
include Git::Lint::Import[:repository, :executor, :environment]
|
14
12
|
|
15
13
|
def call
|
16
|
-
|
17
|
-
|
14
|
+
executor.capture3 "git remote add -f origin #{environment["REPOSITORY_URL"]}"
|
15
|
+
executor.capture3 "git fetch origin #{name}:#{name}"
|
18
16
|
repository.commits "origin/#{repository.branch_default}..origin/#{name}"
|
19
17
|
end
|
20
18
|
|
21
19
|
private
|
22
20
|
|
23
|
-
attr_reader :container
|
24
|
-
|
25
21
|
def name = environment["HEAD"]
|
26
|
-
|
27
|
-
def repository = container[__method__]
|
28
|
-
|
29
|
-
def shell = container[__method__]
|
30
|
-
|
31
|
-
def environment = container[__method__]
|
32
22
|
end
|
33
23
|
end
|
34
24
|
end
|
data/lib/git/lint/container.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "cogger"
|
3
4
|
require "dry-container"
|
4
5
|
require "git_plus"
|
5
|
-
require "
|
6
|
-
require "pastel"
|
6
|
+
require "open3"
|
7
7
|
require "spek"
|
8
8
|
|
9
9
|
module Git
|
@@ -16,29 +16,9 @@ module Git
|
|
16
16
|
register(:environment) { ENV }
|
17
17
|
register(:repository) { GitPlus::Repository.new }
|
18
18
|
register(:specification) { Spek::Loader.call "#{__dir__}/../../../git-lint.gemspec" }
|
19
|
-
register(:colorizer) { Pastel.new enabled: $stdout.tty? }
|
20
19
|
register(:kernel) { Kernel }
|
21
|
-
|
22
|
-
register
|
23
|
-
{
|
24
|
-
"DEBUG" => self[:colorizer].white.detach,
|
25
|
-
"INFO" => self[:colorizer].green.detach,
|
26
|
-
"WARN" => self[:colorizer].yellow.detach,
|
27
|
-
"ERROR" => self[:colorizer].red.detach,
|
28
|
-
"FATAL" => self[:colorizer].white.bold.on_red.detach,
|
29
|
-
"ANY" => self[:colorizer].white.bold.detach
|
30
|
-
}
|
31
|
-
end
|
32
|
-
|
33
|
-
register :logger do
|
34
|
-
Logger.new $stdout,
|
35
|
-
level: Logger.const_get(ENV.fetch("LOG_LEVEL", "INFO")),
|
36
|
-
formatter: (
|
37
|
-
lambda do |severity, _at, _name, message|
|
38
|
-
self[:log_colors][severity].call "#{message}\n"
|
39
|
-
end
|
40
|
-
)
|
41
|
-
end
|
20
|
+
register(:executor) { Open3 }
|
21
|
+
register(:logger) { Cogger::Client.new }
|
42
22
|
end
|
43
23
|
end
|
44
24
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
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:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
@@ -10,9 +10,9 @@ bindir: exe
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
MIIC/
|
14
|
-
|
15
|
-
|
13
|
+
MIIC/jCCAeagAwIBAgIBBTANBgkqhkiG9w0BAQsFADAlMSMwIQYDVQQDDBpicm9v
|
14
|
+
a2UvREM9YWxjaGVtaXN0cy9EQz1pbzAeFw0yMjAzMTkxNzI0MzJaFw0yMzAzMTkx
|
15
|
+
NzI0MzJaMCUxIzAhBgNVBAMMGmJyb29rZS9EQz1hbGNoZW1pc3RzL0RDPWlvMIIB
|
16
16
|
IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6l1qpXTiomH1RfMRloyw7MiE
|
17
17
|
xyVx/x8Yc3EupdH7uhNaTXQGyORN6aOY//1QXXMHIZ9tW74nZLhesWMSUMYy0XhB
|
18
18
|
brs+KkurHnc9FnEJAbG7ebGvl/ncqZt72nQvaxpDxvuCBHgJAz+8i5wl6FhLw+oT
|
@@ -20,30 +20,58 @@ cert_chain:
|
|
20
20
|
D5vkU0YlAm1r98BymuJlcQ1qdkVEI1d48ph4kcS0S0nv1RiuyVb6TCAR3Nu3VaVq
|
21
21
|
3fPzZKJLZBx67UvXdbdicWPiUR75elI4PXpLIic3xytaF52ZJYyKZCNZJhNwfQID
|
22
22
|
AQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU0nzow9vc
|
23
|
-
2CdikiiE3fJhP/
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
23
|
+
2CdikiiE3fJhP/gY4ggwDQYJKoZIhvcNAQELBQADggEBAJbbNyWzFjqUNVPPCUCo
|
24
|
+
IMrhDa9xf1xkORXNYYbmXgoxRy/KyNbUr+jgEEoWJAm9GXlcqxxWAUI6pK/i4/Qi
|
25
|
+
X6rPFEFmeObDOHNvuqy8Hd6AYsu+kP94U/KJhe9wnWGMmGoNKJNU3EkW3jM/osSl
|
26
|
+
+JRxiH5t4WtnDiVyoYl5nYC02rYdjJkG6VMxDymXTqn7u6HhYgZkGujq1UPar8x2
|
27
|
+
hNIWJblDKKSu7hA2d6+kUthuYo13o1sg1Da/AEDg0hoZSUvhqDEF5Hy232qb3pDt
|
28
|
+
CxDe2+VuChj4I1nvIHdu+E6XoEVlanUPKmSg6nddhkKn2gC45Kyzh6FZqnzH/CRp
|
29
|
+
RFE=
|
30
30
|
-----END CERTIFICATE-----
|
31
|
-
date: 2022-
|
31
|
+
date: 2022-04-10 00:00:00.000000000 Z
|
32
32
|
dependencies:
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: auto_injector
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0.4'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0.4'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: cogger
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0.0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0.0'
|
33
61
|
- !ruby/object:Gem::Dependency
|
34
62
|
name: dry-container
|
35
63
|
requirement: !ruby/object:Gem::Requirement
|
36
64
|
requirements:
|
37
65
|
- - "~>"
|
38
66
|
- !ruby/object:Gem::Version
|
39
|
-
version: 0.9
|
67
|
+
version: '0.9'
|
40
68
|
type: :runtime
|
41
69
|
prerelease: false
|
42
70
|
version_requirements: !ruby/object:Gem::Requirement
|
43
71
|
requirements:
|
44
72
|
- - "~>"
|
45
73
|
- !ruby/object:Gem::Version
|
46
|
-
version: 0.9
|
74
|
+
version: '0.9'
|
47
75
|
- !ruby/object:Gem::Dependency
|
48
76
|
name: git_plus
|
49
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -169,16 +197,19 @@ files:
|
|
169
197
|
- lib/git/lint/cli/actions/analyze/branch.rb
|
170
198
|
- lib/git/lint/cli/actions/analyze/commit.rb
|
171
199
|
- lib/git/lint/cli/actions/config.rb
|
200
|
+
- lib/git/lint/cli/actions/container.rb
|
172
201
|
- lib/git/lint/cli/actions/hook.rb
|
202
|
+
- lib/git/lint/cli/actions/import.rb
|
173
203
|
- lib/git/lint/cli/parser.rb
|
174
204
|
- lib/git/lint/cli/parsers/analyze.rb
|
175
205
|
- lib/git/lint/cli/parsers/core.rb
|
176
206
|
- lib/git/lint/cli/shell.rb
|
177
207
|
- lib/git/lint/collector.rb
|
178
|
-
- lib/git/lint/commits/container.rb
|
179
208
|
- lib/git/lint/commits/loader.rb
|
180
209
|
- lib/git/lint/commits/systems/circle_ci.rb
|
210
|
+
- lib/git/lint/commits/systems/container.rb
|
181
211
|
- lib/git/lint/commits/systems/git_hub_action.rb
|
212
|
+
- lib/git/lint/commits/systems/import.rb
|
182
213
|
- lib/git/lint/commits/systems/local.rb
|
183
214
|
- lib/git/lint/commits/systems/netlify_ci.rb
|
184
215
|
- lib/git/lint/configuration/content.rb
|
@@ -189,6 +220,7 @@ files:
|
|
189
220
|
- lib/git/lint/errors/base.rb
|
190
221
|
- lib/git/lint/errors/severity.rb
|
191
222
|
- lib/git/lint/errors/sha.rb
|
223
|
+
- lib/git/lint/import.rb
|
192
224
|
- lib/git/lint/kit/filter_list.rb
|
193
225
|
- lib/git/lint/parsers/trailers/collaborator.rb
|
194
226
|
- lib/git/lint/rake/setup.rb
|
@@ -227,7 +259,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
227
259
|
- !ruby/object:Gem::Version
|
228
260
|
version: '0'
|
229
261
|
requirements: []
|
230
|
-
rubygems_version: 3.3.
|
262
|
+
rubygems_version: 3.3.11
|
231
263
|
signing_key:
|
232
264
|
specification_version: 4
|
233
265
|
summary: A command line interface for linting Git commits.
|
metadata.gz.sig
CHANGED
Binary file
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "dry-container"
|
4
|
-
require "git_plus"
|
5
|
-
|
6
|
-
module Git
|
7
|
-
module Lint
|
8
|
-
module Commits
|
9
|
-
# Provides container specific to this namespace for all systems.
|
10
|
-
module Container
|
11
|
-
extend Dry::Container::Mixin
|
12
|
-
|
13
|
-
config.registry = ->(container, key, value, _options) { container[key.to_s] = value }
|
14
|
-
|
15
|
-
merge Git::Lint::Container
|
16
|
-
|
17
|
-
register(:shell) { Open3 }
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|