git-lint 2.2.0 → 2.3.2
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/README.adoc +22 -132
- data/lib/git/lint/analyzers/abstract.rb +9 -27
- data/lib/git/lint/analyzers/commit_author_capitalization.rb +1 -3
- data/lib/git/lint/analyzers/commit_author_email.rb +1 -3
- data/lib/git/lint/analyzers/commit_author_name.rb +1 -3
- data/lib/git/lint/analyzers/commit_body_bullet.rb +2 -6
- data/lib/git/lint/analyzers/commit_body_bullet_capitalization.rb +3 -9
- data/lib/git/lint/analyzers/commit_body_bullet_delimiter.rb +4 -12
- data/lib/git/lint/analyzers/commit_body_issue_tracker_link.rb +3 -9
- data/lib/git/lint/analyzers/commit_body_line_length.rb +3 -9
- data/lib/git/lint/analyzers/commit_body_paragraph_capitalization.rb +3 -9
- data/lib/git/lint/analyzers/commit_body_phrase.rb +2 -6
- data/lib/git/lint/analyzers/commit_body_presence.rb +2 -4
- data/lib/git/lint/analyzers/commit_body_single_bullet.rb +3 -9
- data/lib/git/lint/analyzers/commit_subject_length.rb +2 -6
- data/lib/git/lint/analyzers/commit_subject_prefix.rb +2 -10
- data/lib/git/lint/analyzers/commit_subject_suffix.rb +1 -3
- data/lib/git/lint/analyzers/commit_trailer_collaborator_capitalization.rb +1 -3
- data/lib/git/lint/analyzers/commit_trailer_collaborator_duplication.rb +1 -3
- data/lib/git/lint/analyzers/commit_trailer_collaborator_email.rb +1 -3
- data/lib/git/lint/analyzers/commit_trailer_collaborator_key.rb +2 -6
- data/lib/git/lint/analyzers/commit_trailer_collaborator_name.rb +2 -6
- data/lib/git/lint/branches/environments/circle_ci.rb +2 -6
- data/lib/git/lint/branches/environments/git_hub_action.rb +2 -6
- data/lib/git/lint/branches/environments/local.rb +2 -6
- data/lib/git/lint/branches/environments/netlify_ci.rb +1 -3
- data/lib/git/lint/branches/environments/travis_ci.rb +4 -12
- data/lib/git/lint/branches/feature.rb +1 -3
- data/lib/git/lint/cli.rb +2 -5
- data/lib/git/lint/collector.rb +10 -30
- data/lib/git/lint/identity.rb +1 -1
- data/lib/git/lint/kit/filter_list.rb +3 -9
- data/lib/git/lint/parsers/trailers/collaborator.rb +4 -12
- data/lib/git/lint/rake/tasks.rb +1 -3
- data/lib/git/lint/refinements/strings.rb +2 -6
- data/lib/git/lint/reporters/branch.rb +1 -1
- data/lib/git/lint/reporters/commit.rb +1 -3
- data/lib/git/lint/reporters/line.rb +1 -3
- data/lib/git/lint/reporters/lines/paragraph.rb +5 -15
- data/lib/git/lint/reporters/lines/sentence.rb +3 -9
- data/lib/git/lint/reporters/style.rb +1 -3
- data/lib/git/lint/validators/capitalization.rb +2 -6
- data/lib/git/lint/validators/email.rb +1 -3
- data/lib/git/lint/validators/name.rb +2 -6
- metadata +5 -5
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2738d9812647c24090cf0465db57379709af0fd64c9c8aa474f7d68c2f7896f5
|
4
|
+
data.tar.gz: f258c1a530ce3faf4f115feb2a108d021f09959eda092be58d92b75b8b5862d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44551a125b11785cdadbb3d65e63c049e2a513704ebef7f21419c95b21c396ac8f2193bd7f2bf35d4f30469789236b793a3cd1f2a3554efc715b0ebcaa4621e4
|
7
|
+
data.tar.gz: d6f8299c1c864fe7cfde0a692119b3bab8f1450ce89df534b76ac3c84d31cb54576cc2a45f300fdb8afd3cdfbd539f029aab88967e0bc7184ec9a4a0c8a01396
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/README.adoc
CHANGED
@@ -731,12 +731,12 @@ Automatically ignores _fixup!_ or _squash!_ commit prefixes when calculating sub
|
|
731
731
|
| true | error | includes: (see below)
|
732
732
|
|===
|
733
733
|
|
734
|
-
Ensures
|
734
|
+
Ensures each commit subject uses consistent prefixes that explain _what_ is being committed. The
|
735
735
|
`includes` are _case sensitive_ and default to the following prefixes:
|
736
736
|
|
737
737
|
* *Fixed* - Identifies what was fixed. The commit should be as small as possible and consist of
|
738
|
-
changes to implementation and spec only. In some cases this might be a single line
|
739
|
-
|
738
|
+
changes to implementation and spec only. In some cases this might be a single line change. The
|
739
|
+
important point is the change is applied to existing code which corrects behavior that wasn't
|
740
740
|
properly implemented earlier.
|
741
741
|
* *Removed* - Identifies what was removed. The commit should be as small as possible and consist
|
742
742
|
only of removed lines/files from the existing implementation. This might also mean breaking
|
@@ -747,18 +747,24 @@ Ensures the commit subject uses consistent prefixes that explain _what_ is being
|
|
747
747
|
* *Updated* - Identifies what was updated. The commit should be as small as possible and _not add
|
748
748
|
or fix_ existing behavior. This can sometimes be a grey area but is typically reserved for updates
|
749
749
|
to documentation, code comments, dependencies, etc.
|
750
|
-
* *Refactored* - Identifies what was refactored.
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
750
|
+
* *Refactored* - Identifies what was refactored.
|
751
|
+
link:https://thoughtbot.com/blog/lets-not-misuse-refactoring[_Refactoring is for changing code
|
752
|
+
structure without changing observable behavior_]. The commit should be as small as possible and
|
753
|
+
not mix multiple kinds of changes at once. Refactored code should never break existing
|
754
|
+
implementation behavior or corresponding specs because, if that happens, then one of the other
|
755
|
+
four prefixes is what you want to use instead.
|
756
|
+
|
757
|
+
In practice, it is quite rare to need a prefix other than what has been detailed above to explain
|
758
|
+
_what_ is being committed. These prefixes are not only short and easy to remember but also have the
|
756
759
|
added benefit of categorizing the commits for building release notes, change logs, etc. This becomes
|
757
|
-
handy when coupled with another tool,
|
758
|
-
for producing consistent project
|
760
|
+
handy when coupled with another tool,
|
761
|
+
link:https://www.alchemists.io/projects/milestoner[Milestoner], for producing consistent project
|
762
|
+
milestones and Git tag histories. For a deeper dive on subject prefixes and good commit messages in
|
763
|
+
general, please read about link:https://www.alchemists.io/articles/git_commit_anatomy[commit anatomy
|
764
|
+
] to learn more. 🎉
|
759
765
|
|
760
|
-
|
761
|
-
disturb interactive rebase workflows.
|
766
|
+
💡 This analyzer automatically ignores _amend!_, _fixup!_, or _squash!_ commit prefixes when used as
|
767
|
+
a Git Hook in order to not disturb interactive rebase workflows.
|
762
768
|
|
763
769
|
=== Commit Subject Suffix
|
764
770
|
|
@@ -947,7 +953,7 @@ configuration disabled.
|
|
947
953
|
|
948
954
|
=== Tags
|
949
955
|
|
950
|
-
* Use tags to denote milestones/releases:
|
956
|
+
* Use tags to denote link:https://www.alchemists.io/projects/milestoner[milestones]/releases:
|
951
957
|
** Makes it easier to record milestones and capture associated release notes.
|
952
958
|
** Makes it easier to compare differences between versions.
|
953
959
|
** Provides a starting point for debugging production issues (if any).
|
@@ -972,124 +978,8 @@ configuration disabled.
|
|
972
978
|
|
973
979
|
=== Code Reviews
|
974
980
|
|
975
|
-
|
976
|
-
|
977
|
-
. *Joy* - The experience of working with you, receiving feedback, giving feedback, and demonstrating
|
978
|
-
a level of care influences others and encourages a collaborative environment that is fun to work
|
979
|
-
in. Use this time to build and reinforce trust amongst your fellow colleagues.
|
980
|
-
. *Quality*: Ensures changes are of highest quality that adhere to team standards while enhancing
|
981
|
-
the customer experience and not disrupting their workflow.
|
982
|
-
. *Education*: Provides a chance for everyone on the team to learn more about the architecture,
|
983
|
-
product/service, and how each member of the team implements a solution. This is your chance to
|
984
|
-
ask questions and learn how to be a better engineer so take advantage of it.
|
985
|
-
|
986
|
-
In addition to the objectives above, the following guidelines are worth following:
|
987
|
-
|
988
|
-
* Keep code reviews short and easy to review:
|
989
|
-
** Review your own code first before submitting to others. By ensuring your are confident in the
|
990
|
-
overall implementation and the commits in terms of commit messages and implementation details,
|
991
|
-
you'll encourage higher quality feedback and show appreciation for the reviewer's time.
|
992
|
-
** Provide a high level overview that answers _why_ the code review is necessary.
|
993
|
-
** Provide a link to the issue that prompted the code review (if any) and any additional details
|
994
|
-
worth highlighting to guide the reviewer through the process.
|
995
|
-
** Provide screenshots/screencasts if possible.
|
996
|
-
** Provide any ancillary notes or points of interest worth highlighting for the reviewer.
|
997
|
-
** Ensure commits within the code review are related to the purpose of the code review and avoid
|
998
|
-
mixing in changes that are ancillary to the primary objective of the code view. If you do have
|
999
|
-
changes outside of the scope of the current code review, open those changes up as a separate code
|
1000
|
-
review instead.
|
1001
|
-
** Prefer code reviews at about 300 lines in order to keep the quality of the code review and defect
|
1002
|
-
detection high. This also shows you value the reviewers time and attention away from their own
|
1003
|
-
work.
|
1004
|
-
** Avoid working on a large issues without first getting feedback in order to not overwhelm/surprise
|
1005
|
-
the maintainers. More discussion up front will help ensure your work has a faster chance of
|
1006
|
-
acceptance.
|
1007
|
-
* Review and rebase code reviews quickly:
|
1008
|
-
** Maintain a consistent but reasonable pace -- Review morning, noon, and night.
|
1009
|
-
** Avoid letting code reviews linger more than a day. Otherwise, you risk hampering moral and
|
1010
|
-
diminishing the productivity of the team.
|
1011
|
-
* Use emojis, with a format of `<emoji> <feedback>`, to identify the kinds of feedback used during
|
1012
|
-
the review process:
|
1013
|
-
** 🍵 (`:tea:`) - Signifies you are starting the code review. This is _non-blocking_ and
|
1014
|
-
informational. Useful when reading over a code review with a large number of commits, complex
|
1015
|
-
code, requires additional testing by the reviewer, etc.
|
1016
|
-
** ⭐️ (`:star:`) - Signifies code that is liked, favorited, remarkable, etc. This feedback is
|
1017
|
-
_non-blocking_ and is always meant to be positive/uplifting.
|
1018
|
-
** ℹ️ (`:information_source:`) - Signifies informational feedback that is
|
1019
|
-
_non-blocking_. Can also be used to let one know you are done reviewing but haven't approved yet
|
1020
|
-
(due to feedback that needs addressing), rebasing a code review and then merging, waiting for a
|
1021
|
-
blocking code review to be resolved, status updates to the code review, etc.
|
1022
|
-
** 💭 (`:thought_balloon:`) - Signifies inquisitive intent that is _non-blocking_.
|
1023
|
-
Useful when asking questions and/or probing deeper into implementation details to learn more.
|
1024
|
-
** 🔤 (`:abc:`) - Signifies detection of a misspelling with suggested correction. This is
|
1025
|
-
_blocking_ feedback that is easy to correct.
|
1026
|
-
** 🎨 (`:art:`) - Signifies an issue with code style and/or code quality. This can be _blocking_
|
1027
|
-
or _non-blocking_ feedback. It is up to the discretion of the author on how to address the
|
1028
|
-
feedback but encouraged that the feedback is incorporated or at least discussed. Generally,
|
1029
|
-
these situations are automatically detected via code linters but there are occasions where
|
1030
|
-
there is ambiguity in which linters can't catch.
|
1031
|
-
** 🏛 (`:classical_building:`) - Signifies an issue with the architecture of the
|
1032
|
-
implementation. This is _blocking_ and requires immediate correction. The reviewer should
|
1033
|
-
provide a suggested solution and/or links to patterns, articles, etc. that might help the author
|
1034
|
-
fix the implementation. Pairing is encouraged if feedback is vast and/or complex.
|
1035
|
-
** 🔓 (`:unlock:`) - Signifies a security violation that would damage us and/or our customers. This
|
1036
|
-
is _blocking_ feedback and must be addressed immediately.
|
1037
|
-
** 💡 (`:bulb:`) - Indicates a helpful tip or trick for improving the code. This can be
|
1038
|
-
_blocking_ or _non-blocking_ feedback and is left up to the author to decide. Generally, it is a
|
1039
|
-
good idea to address and resolve the feedback.
|
1040
|
-
** 🙇 (`:bow:`) - Indicates thankfulness of the feedback received. This is _non-blocking_ and
|
1041
|
-
always meant as a response to helpful feedback.
|
1042
|
-
** ✅ (`:white_check_mark:`) - Signifies code review approval. The author can
|
1043
|
-
rebase onto `main` and delete the feature branch at this point.
|
1044
|
-
* Use all feedback as a chance to learn, teach, strenghen the bond of trust between you and your
|
1045
|
-
fellow colleagues, and avoid being cut by
|
1046
|
-
link:https://fs.blog/2017/04/mental-model-hanlons-razor[Hanlon's Razor].
|
1047
|
-
* Use automation to ensure code reviews are consistent, of high quality, and swift to resolve. Each
|
1048
|
-
code review can be an opportunity to identify and automate the process further.
|
1049
|
-
* Use face-to-face communication if a code review's written discussion gets lengthy/noisy.
|
1050
|
-
* Create follow-up actions if additional features are discovered during a code review to avoid
|
1051
|
-
delaying code review acceptance. Return to the code review once the new actions have been logged.
|
1052
|
-
* The author, not the reviewer, should rebase the feature branch onto `main` upon approval.
|
1053
|
-
* Avoid reviewing your own code review before rebasing onto `main`. Have another pair of eyes
|
1054
|
-
review your code first.
|
1055
|
-
* Ensure the following criteria is met before rebasing your feature branch to `main`:
|
1056
|
-
** Ensure all `fixup!` and `squash!` commits are interactively rebased. _Avoid rebasing these onto
|
1057
|
-
the `main` branch!_
|
1058
|
-
** Ensure your feature branch is rebased upon `main`.
|
1059
|
-
** Ensure all tests and code quality checks are passing.
|
1060
|
-
** Ensure the feature branch is deleted after being successfully rebased.
|
1061
|
-
|
1062
|
-
=== GitHub
|
1063
|
-
|
1064
|
-
When using GitHub, enforce a rebase workflow for all of your GitHub projects (_highly recommended_).
|
1065
|
-
You can do this via your project options (i.e. `https://github.com/<username/<project>/settings`)
|
1066
|
-
and editing your merge options for code reviews as follows:
|
1067
|
-
|
1068
|
-
image::https://www.alchemists.io/images/projects/git-lint/screenshots/github-settings-options.png[GitHub Merge Options]
|
1069
|
-
|
1070
|
-
In addition to the above, you'll want to add _branch_ protection rules for your `main` branch. To
|
1071
|
-
do this, follow these steps:
|
1072
|
-
|
1073
|
-
. Visit your branch settings (i.e. `https://github.com/<username>/<project>/settings/branches`).
|
1074
|
-
. Click the _Add rule_ button.
|
1075
|
-
. For _branch name pattern_, enter: `main`.
|
1076
|
-
. Check _Require pull request reviews before merging_.
|
1077
|
-
. Set _Required approving reviews_ to `2` as a minimum.
|
1078
|
-
. Check _Dismiss stale pull request approvals when new commits are pushed_.
|
1079
|
-
. Check _Require review from Code Owners_.
|
1080
|
-
. Check _Require status checks to pass before merging_.
|
1081
|
-
. Check _Require branches to be up to date before merging_.
|
1082
|
-
. Check _Require signed commits_.
|
1083
|
-
. Check _Require linear history_ (pairs well with the merge options mentioned above).
|
1084
|
-
. Check _Include administrators_.
|
1085
|
-
. Uncheck _Allow force pushes_.
|
1086
|
-
. Uncheck _Allow deletions_.
|
1087
|
-
|
1088
|
-
With the above applied, you should have the following result:
|
1089
|
-
|
1090
|
-
image::https://www.alchemists.io/images/projects/git-lint/screenshots/github-settings-branch_protections.png[GitHub Branch Protections]
|
1091
|
-
|
1092
|
-
Applying the above changes will help maintain a clean Git history.
|
981
|
+
For an in depth look at how to conduct code reviews, please read my
|
982
|
+
link:https://www.alchemists.io/articles/code_reviews[article] on this subject to learn more.
|
1093
983
|
|
1094
984
|
== Development
|
1095
985
|
|
@@ -18,25 +18,17 @@ module Git
|
|
18
18
|
@descendants << klass unless klass.to_s.start_with? "#<Class" # Ignore anonymous classes.
|
19
19
|
end
|
20
20
|
|
21
|
-
def self.id
|
22
|
-
to_s.delete_prefix("Git::Lint::Analyzers").snakecase.to_sym
|
23
|
-
end
|
21
|
+
def self.id = to_s.delete_prefix("Git::Lint::Analyzers").snakecase.to_sym
|
24
22
|
|
25
|
-
def self.label
|
26
|
-
to_s.delete_prefix("Git::Lint::Analyzers").titleize
|
27
|
-
end
|
23
|
+
def self.label = to_s.delete_prefix("Git::Lint::Analyzers").titleize
|
28
24
|
|
29
25
|
def self.defaults
|
30
26
|
fail NotImplementedError, "The `.#{__method__}` method must be implemented."
|
31
27
|
end
|
32
28
|
|
33
|
-
def self.descendants
|
34
|
-
@descendants || []
|
35
|
-
end
|
29
|
+
def self.descendants = @descendants || []
|
36
30
|
|
37
|
-
def self.build_issue_line index, line
|
38
|
-
{number: index + ISSUE_LINE_OFFSET, content: line}
|
39
|
-
end
|
31
|
+
def self.build_issue_line(index, line) = {number: index + ISSUE_LINE_OFFSET, content: line}
|
40
32
|
|
41
33
|
attr_reader :commit
|
42
34
|
|
@@ -46,9 +38,7 @@ module Git
|
|
46
38
|
@filter_list = load_filter_list
|
47
39
|
end
|
48
40
|
|
49
|
-
def enabled?
|
50
|
-
settings.fetch :enabled
|
51
|
-
end
|
41
|
+
def enabled? = settings.fetch(:enabled)
|
52
42
|
|
53
43
|
def severity
|
54
44
|
settings.fetch(:severity).tap do |level|
|
@@ -60,17 +50,11 @@ module Git
|
|
60
50
|
fail NotImplementedError, "The `##{__method__}` method must be implemented."
|
61
51
|
end
|
62
52
|
|
63
|
-
def invalid?
|
64
|
-
!valid?
|
65
|
-
end
|
53
|
+
def invalid? = !valid?
|
66
54
|
|
67
|
-
def warning?
|
68
|
-
invalid? && severity == :warn
|
69
|
-
end
|
55
|
+
def warning? = invalid? && severity == :warn
|
70
56
|
|
71
|
-
def error?
|
72
|
-
invalid? && severity == :error
|
73
|
-
end
|
57
|
+
def error? = invalid? && severity == :error
|
74
58
|
|
75
59
|
def issue
|
76
60
|
fail NotImplementedError, "The `##{__method__}` method must be implemented."
|
@@ -80,9 +64,7 @@ module Git
|
|
80
64
|
|
81
65
|
attr_reader :settings, :filter_list
|
82
66
|
|
83
|
-
def load_filter_list
|
84
|
-
Kit::FilterList.new settings[:list]
|
85
|
-
end
|
67
|
+
def load_filter_list = Kit::FilterList.new(settings[:list])
|
86
68
|
|
87
69
|
def affected_commit_body_lines
|
88
70
|
commit.body_lines.each.with_object([]).with_index do |(line, lines), index|
|
@@ -12,9 +12,7 @@ module Git
|
|
12
12
|
}
|
13
13
|
end
|
14
14
|
|
15
|
-
def valid?
|
16
|
-
commit.body_lines.all? { |line| !invalid_line? line }
|
17
|
-
end
|
15
|
+
def valid? = commit.body_lines.all? { |line| !invalid_line? line }
|
18
16
|
|
19
17
|
def issue
|
20
18
|
return {} if valid?
|
@@ -27,9 +25,7 @@ module Git
|
|
27
25
|
|
28
26
|
protected
|
29
27
|
|
30
|
-
def load_filter_list
|
31
|
-
Kit::FilterList.new settings.fetch :excludes
|
32
|
-
end
|
28
|
+
def load_filter_list = Kit::FilterList.new(settings.fetch(:excludes))
|
33
29
|
|
34
30
|
# :reek:FeatureEnvy
|
35
31
|
def invalid_line? line
|
@@ -12,9 +12,7 @@ module Git
|
|
12
12
|
}
|
13
13
|
end
|
14
14
|
|
15
|
-
def valid?
|
16
|
-
lowercased_bullets.size.zero?
|
17
|
-
end
|
15
|
+
def valid? = lowercased_bullets.size.zero?
|
18
16
|
|
19
17
|
def issue
|
20
18
|
return {} if valid?
|
@@ -27,9 +25,7 @@ module Git
|
|
27
25
|
|
28
26
|
protected
|
29
27
|
|
30
|
-
def load_filter_list
|
31
|
-
Kit::FilterList.new settings.fetch :includes
|
32
|
-
end
|
28
|
+
def load_filter_list = Kit::FilterList.new(settings.fetch(:includes))
|
33
29
|
|
34
30
|
def invalid_line? line
|
35
31
|
line.match?(/\A\s*#{Regexp.union filter_list.to_regexp}\s[[:lower:]]+/)
|
@@ -37,9 +33,7 @@ module Git
|
|
37
33
|
|
38
34
|
private
|
39
35
|
|
40
|
-
def lowercased_bullets
|
41
|
-
commit.body_lines.select { |line| invalid_line? line }
|
42
|
-
end
|
36
|
+
def lowercased_bullets = commit.body_lines.select { |line| invalid_line? line }
|
43
37
|
end
|
44
38
|
end
|
45
39
|
end
|
@@ -12,9 +12,7 @@ module Git
|
|
12
12
|
}
|
13
13
|
end
|
14
14
|
|
15
|
-
def valid?
|
16
|
-
commit.body_lines.none? { |line| invalid_line? line }
|
17
|
-
end
|
15
|
+
def valid? = commit.body_lines.none? { |line| invalid_line? line }
|
18
16
|
|
19
17
|
def issue
|
20
18
|
return {} if valid?
|
@@ -27,17 +25,11 @@ module Git
|
|
27
25
|
|
28
26
|
protected
|
29
27
|
|
30
|
-
def load_filter_list
|
31
|
-
Kit::FilterList.new settings.fetch :includes
|
32
|
-
end
|
28
|
+
def load_filter_list = Kit::FilterList.new(settings.fetch(:includes))
|
33
29
|
|
34
|
-
def invalid_line? line
|
35
|
-
line.match?(/\A\s*#{pattern}(?!(#{pattern}|\s)).+\Z/)
|
36
|
-
end
|
30
|
+
def invalid_line?(line) = line.match?(/\A\s*#{pattern}(?!(#{pattern}|\s)).+\Z/)
|
37
31
|
|
38
|
-
def pattern
|
39
|
-
Regexp.union filter_list.to_regexp
|
40
|
-
end
|
32
|
+
def pattern = Regexp.union(filter_list.to_regexp)
|
41
33
|
end
|
42
34
|
end
|
43
35
|
end
|
@@ -17,9 +17,7 @@ module Git
|
|
17
17
|
}
|
18
18
|
end
|
19
19
|
|
20
|
-
def valid?
|
21
|
-
commit.body_lines.none? { |line| invalid_line? line }
|
22
|
-
end
|
20
|
+
def valid? = commit.body_lines.none? { |line| invalid_line? line }
|
23
21
|
|
24
22
|
def issue
|
25
23
|
return {} if valid?
|
@@ -32,13 +30,9 @@ module Git
|
|
32
30
|
|
33
31
|
protected
|
34
32
|
|
35
|
-
def load_filter_list
|
36
|
-
Kit::FilterList.new settings.fetch :excludes
|
37
|
-
end
|
33
|
+
def load_filter_list = Kit::FilterList.new(settings.fetch(:excludes))
|
38
34
|
|
39
|
-
def invalid_line? line
|
40
|
-
line.match?(/.*#{Regexp.union filter_list.to_regexp}.*/)
|
41
|
-
end
|
35
|
+
def invalid_line?(line) = line.match?(/.*#{Regexp.union filter_list.to_regexp}.*/)
|
42
36
|
end
|
43
37
|
end
|
44
38
|
end
|
@@ -12,9 +12,7 @@ module Git
|
|
12
12
|
}
|
13
13
|
end
|
14
14
|
|
15
|
-
def valid?
|
16
|
-
commit.body_lines.all? { |line| !invalid_line? line }
|
17
|
-
end
|
15
|
+
def valid? = commit.body_lines.all? { |line| !invalid_line? line }
|
18
16
|
|
19
17
|
def issue
|
20
18
|
return {} if valid?
|
@@ -27,15 +25,11 @@ module Git
|
|
27
25
|
|
28
26
|
protected
|
29
27
|
|
30
|
-
def invalid_line? line
|
31
|
-
line.length > length
|
32
|
-
end
|
28
|
+
def invalid_line?(line) = line.length > length
|
33
29
|
|
34
30
|
private
|
35
31
|
|
36
|
-
def length
|
37
|
-
settings.fetch :length
|
38
|
-
end
|
32
|
+
def length = settings.fetch(:length)
|
39
33
|
end
|
40
34
|
end
|
41
35
|
end
|
@@ -11,13 +11,9 @@ module Git
|
|
11
11
|
}
|
12
12
|
end
|
13
13
|
|
14
|
-
def self.invalid? line
|
15
|
-
line.match?(/\A[[:lower:]].+\Z/m)
|
16
|
-
end
|
14
|
+
def self.invalid?(line) = line.match?(/\A[[:lower:]].+\Z/m)
|
17
15
|
|
18
|
-
def valid?
|
19
|
-
lowercased_lines.empty?
|
20
|
-
end
|
16
|
+
def valid? = lowercased_lines.empty?
|
21
17
|
|
22
18
|
def issue
|
23
19
|
return {} if valid?
|
@@ -30,9 +26,7 @@ module Git
|
|
30
26
|
|
31
27
|
private
|
32
28
|
|
33
|
-
def lowercased_lines
|
34
|
-
commit.body_paragraphs.select { |line| self.class.invalid? line }
|
35
|
-
end
|
29
|
+
def lowercased_lines = commit.body_paragraphs.select { |line| self.class.invalid? line }
|
36
30
|
|
37
31
|
def affected_lines
|
38
32
|
klass = self.class
|
@@ -41,9 +41,7 @@ module Git
|
|
41
41
|
end
|
42
42
|
# rubocop:enable Metrics/MethodLength
|
43
43
|
|
44
|
-
def valid?
|
45
|
-
commit.body_lines.all? { |line| !invalid_line? line }
|
46
|
-
end
|
44
|
+
def valid? = commit.body_lines.all? { |line| !invalid_line? line }
|
47
45
|
|
48
46
|
def issue
|
49
47
|
return {} if valid?
|
@@ -56,9 +54,7 @@ module Git
|
|
56
54
|
|
57
55
|
protected
|
58
56
|
|
59
|
-
def load_filter_list
|
60
|
-
Kit::FilterList.new settings.fetch(:excludes)
|
61
|
-
end
|
57
|
+
def load_filter_list = Kit::FilterList.new(settings.fetch(:excludes))
|
62
58
|
|
63
59
|
def invalid_line? line
|
64
60
|
line.downcase.match? Regexp.new(
|
@@ -4,7 +4,7 @@ module Git
|
|
4
4
|
module Lint
|
5
5
|
module Analyzers
|
6
6
|
class CommitBodyPresence < Abstract
|
7
|
-
using Refinements::Strings
|
7
|
+
using GitPlus::Refinements::Strings
|
8
8
|
|
9
9
|
def self.defaults
|
10
10
|
{
|
@@ -21,9 +21,7 @@ module Git
|
|
21
21
|
valid_lines.size >= minimum
|
22
22
|
end
|
23
23
|
|
24
|
-
def minimum
|
25
|
-
settings.fetch :minimum
|
26
|
-
end
|
24
|
+
def minimum = settings.fetch(:minimum)
|
27
25
|
|
28
26
|
def issue
|
29
27
|
return {} if valid?
|
@@ -12,9 +12,7 @@ module Git
|
|
12
12
|
}
|
13
13
|
end
|
14
14
|
|
15
|
-
def valid?
|
16
|
-
affected_commit_body_lines.size != 1
|
17
|
-
end
|
15
|
+
def valid? = affected_commit_body_lines.size != 1
|
18
16
|
|
19
17
|
def issue
|
20
18
|
return {} if valid?
|
@@ -27,13 +25,9 @@ module Git
|
|
27
25
|
|
28
26
|
protected
|
29
27
|
|
30
|
-
def load_filter_list
|
31
|
-
Kit::FilterList.new settings.fetch :includes
|
32
|
-
end
|
28
|
+
def load_filter_list = Kit::FilterList.new(settings.fetch(:includes))
|
33
29
|
|
34
|
-
def invalid_line? line
|
35
|
-
line.match?(/\A#{Regexp.union filter_list.to_regexp}\s+/)
|
36
|
-
end
|
30
|
+
def invalid_line?(line) = line.match?(/\A#{Regexp.union filter_list.to_regexp}\s+/)
|
37
31
|
end
|
38
32
|
end
|
39
33
|
end
|
@@ -12,9 +12,7 @@ module Git
|
|
12
12
|
}
|
13
13
|
end
|
14
14
|
|
15
|
-
def valid?
|
16
|
-
commit.subject.sub(/(fixup!|squash!)\s{1}/, "").size <= length
|
17
|
-
end
|
15
|
+
def valid? = commit.subject.sub(/(fixup!|squash!)\s{1}/, "").size <= length
|
18
16
|
|
19
17
|
def issue
|
20
18
|
return {} if valid?
|
@@ -24,9 +22,7 @@ module Git
|
|
24
22
|
|
25
23
|
private
|
26
24
|
|
27
|
-
def length
|
28
|
-
settings.fetch :length
|
29
|
-
end
|
25
|
+
def length = settings.fetch(:length)
|
30
26
|
end
|
31
27
|
end
|
32
28
|
end
|
@@ -13,7 +13,7 @@ module Git
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def valid?
|
16
|
-
return true if
|
16
|
+
return true if commit.prefix?
|
17
17
|
return true if filter_list.empty?
|
18
18
|
|
19
19
|
commit.subject.match?(/\A#{Regexp.union filter_list.to_regexp}/)
|
@@ -27,15 +27,7 @@ module Git
|
|
27
27
|
|
28
28
|
protected
|
29
29
|
|
30
|
-
def load_filter_list
|
31
|
-
Kit::FilterList.new settings.fetch(:includes)
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def fixup_or_squash?
|
37
|
-
commit.fixup? || commit.squash?
|
38
|
-
end
|
30
|
+
def load_filter_list = Kit::FilterList.new(settings.fetch(:includes))
|
39
31
|
end
|
40
32
|
end
|
41
33
|
end
|
@@ -19,9 +19,7 @@ module Git
|
|
19
19
|
@parser = parser
|
20
20
|
end
|
21
21
|
|
22
|
-
def valid?
|
23
|
-
affected_commit_trailers.empty?
|
24
|
-
end
|
22
|
+
def valid? = affected_commit_trailers.empty?
|
25
23
|
|
26
24
|
def issue
|
27
25
|
return {} if valid?
|
@@ -34,9 +32,7 @@ module Git
|
|
34
32
|
|
35
33
|
protected
|
36
34
|
|
37
|
-
def load_filter_list
|
38
|
-
Kit::FilterList.new settings.fetch :includes
|
39
|
-
end
|
35
|
+
def load_filter_list = Kit::FilterList.new(settings.fetch(:includes))
|
40
36
|
|
41
37
|
def invalid_line? line
|
42
38
|
collaborator = parser.new line
|
@@ -24,9 +24,7 @@ module Git
|
|
24
24
|
end
|
25
25
|
# rubocop:enable Metrics/ParameterLists
|
26
26
|
|
27
|
-
def valid?
|
28
|
-
affected_commit_trailers.empty?
|
29
|
-
end
|
27
|
+
def valid? = affected_commit_trailers.empty?
|
30
28
|
|
31
29
|
def issue
|
32
30
|
return {} if valid?
|
@@ -48,9 +46,7 @@ module Git
|
|
48
46
|
|
49
47
|
attr_reader :parser, :validator
|
50
48
|
|
51
|
-
def minimum
|
52
|
-
settings.fetch :minimum
|
53
|
-
end
|
49
|
+
def minimum = settings.fetch(:minimum)
|
54
50
|
end
|
55
51
|
end
|
56
52
|
end
|
@@ -10,13 +10,9 @@ module Git
|
|
10
10
|
@repository = repository
|
11
11
|
end
|
12
12
|
|
13
|
-
def name
|
14
|
-
"origin/#{repository.branch_name}"
|
15
|
-
end
|
13
|
+
def name = "origin/#{repository.branch_name}"
|
16
14
|
|
17
|
-
def commits
|
18
|
-
repository.commits "origin/#{repository.branch_default}..#{name}"
|
19
|
-
end
|
15
|
+
def commits = repository.commits("origin/#{repository.branch_default}..#{name}")
|
20
16
|
|
21
17
|
private
|
22
18
|
|
@@ -10,13 +10,9 @@ module Git
|
|
10
10
|
@repository = repository
|
11
11
|
end
|
12
12
|
|
13
|
-
def name
|
14
|
-
"origin/#{repository.branch_name}"
|
15
|
-
end
|
13
|
+
def name = "origin/#{repository.branch_name}"
|
16
14
|
|
17
|
-
def commits
|
18
|
-
repository.commits "origin/#{repository.branch_default}..#{name}"
|
19
|
-
end
|
15
|
+
def commits = repository.commits("origin/#{repository.branch_default}..#{name}")
|
20
16
|
|
21
17
|
private
|
22
18
|
|
@@ -10,13 +10,9 @@ module Git
|
|
10
10
|
@repository = repository
|
11
11
|
end
|
12
12
|
|
13
|
-
def name
|
14
|
-
repository.branch_name
|
15
|
-
end
|
13
|
+
def name = repository.branch_name
|
16
14
|
|
17
|
-
def commits
|
18
|
-
repository.commits "#{repository.branch_default}..#{name}"
|
19
|
-
end
|
15
|
+
def commits = repository.commits("#{repository.branch_default}..#{name}")
|
20
16
|
|
21
17
|
private
|
22
18
|
|
@@ -14,9 +14,7 @@ module Git
|
|
14
14
|
@environment = environment
|
15
15
|
end
|
16
16
|
|
17
|
-
def name
|
18
|
-
pull_request_branch.empty? ? ci_branch : pull_request_branch
|
19
|
-
end
|
17
|
+
def name = pull_request_branch.empty? ? ci_branch : pull_request_branch
|
20
18
|
|
21
19
|
def commits
|
22
20
|
prepare_project
|
@@ -39,17 +37,11 @@ module Git
|
|
39
37
|
shell.capture3 "git fetch"
|
40
38
|
end
|
41
39
|
|
42
|
-
def ci_branch
|
43
|
-
environment["TRAVIS_BRANCH"]
|
44
|
-
end
|
40
|
+
def ci_branch = environment["TRAVIS_BRANCH"]
|
45
41
|
|
46
|
-
def pull_request_branch
|
47
|
-
environment["TRAVIS_PULL_REQUEST_BRANCH"]
|
48
|
-
end
|
42
|
+
def pull_request_branch = environment["TRAVIS_PULL_REQUEST_BRANCH"]
|
49
43
|
|
50
|
-
def pull_request_slug
|
51
|
-
environment["TRAVIS_PULL_REQUEST_SLUG"]
|
52
|
-
end
|
44
|
+
def pull_request_slug = environment["TRAVIS_PULL_REQUEST_SLUG"]
|
53
45
|
end
|
54
46
|
end
|
55
47
|
end
|
data/lib/git/lint/cli.rb
CHANGED
@@ -71,17 +71,14 @@ module Git
|
|
71
71
|
|
72
72
|
desc "--hook", "Add Git Hook support."
|
73
73
|
map "--hook" => :hook
|
74
|
-
method_option :commit_message,
|
75
|
-
desc: "Analyze commit message.",
|
76
|
-
banner: "PATH",
|
77
|
-
type: :string
|
74
|
+
method_option :commit_message, desc: "Analyze commit message.", banner: "PATH", type: :string
|
78
75
|
def hook
|
79
76
|
if options.commit_message?
|
80
77
|
check_commit_message options.commit_message
|
81
78
|
else
|
82
79
|
help "--hook"
|
83
80
|
end
|
84
|
-
rescue Errors::Base, GitPlus::
|
81
|
+
rescue Errors::Base, GitPlus::Error => error
|
85
82
|
abort colorizer.red("#{Identity::LABEL}: #{error.message}")
|
86
83
|
end
|
87
84
|
|
data/lib/git/lint/collector.rb
CHANGED
@@ -16,45 +16,25 @@ module Git
|
|
16
16
|
analyzer
|
17
17
|
end
|
18
18
|
|
19
|
-
def retrieve id
|
20
|
-
collection[id]
|
21
|
-
end
|
19
|
+
def retrieve(id) = collection[id]
|
22
20
|
|
23
|
-
def empty?
|
24
|
-
collection.empty?
|
25
|
-
end
|
21
|
+
def empty? = collection.empty?
|
26
22
|
|
27
|
-
def warnings?
|
28
|
-
collection.values.flatten.any?(&:warning?)
|
29
|
-
end
|
23
|
+
def warnings? = collection.values.flatten.any?(&:warning?)
|
30
24
|
|
31
|
-
def errors?
|
32
|
-
collection.values.flatten.any?(&:error?)
|
33
|
-
end
|
25
|
+
def errors? = collection.values.flatten.any?(&:error?)
|
34
26
|
|
35
|
-
def issues?
|
36
|
-
collection.values.flatten.any?(&:invalid?)
|
37
|
-
end
|
27
|
+
def issues? = collection.values.flatten.any?(&:invalid?)
|
38
28
|
|
39
|
-
def total_warnings
|
40
|
-
collection.values.flatten.count(&:warning?)
|
41
|
-
end
|
29
|
+
def total_warnings = collection.values.flatten.count(&:warning?)
|
42
30
|
|
43
|
-
def total_errors
|
44
|
-
collection.values.flatten.count(&:error?)
|
45
|
-
end
|
31
|
+
def total_errors = collection.values.flatten.count(&:error?)
|
46
32
|
|
47
|
-
def total_issues
|
48
|
-
collection.values.flatten.count(&:invalid?)
|
49
|
-
end
|
33
|
+
def total_issues = collection.values.flatten.count(&:invalid?)
|
50
34
|
|
51
|
-
def total_commits
|
52
|
-
collection.keys.size
|
53
|
-
end
|
35
|
+
def total_commits = collection.keys.size
|
54
36
|
|
55
|
-
def to_h
|
56
|
-
collection
|
57
|
-
end
|
37
|
+
def to_h = collection
|
58
38
|
|
59
39
|
private
|
60
40
|
|
data/lib/git/lint/identity.rb
CHANGED
@@ -9,17 +9,11 @@ module Git
|
|
9
9
|
@list = Array list
|
10
10
|
end
|
11
11
|
|
12
|
-
def to_hint
|
13
|
-
to_regexp.map(&:inspect).join ", "
|
14
|
-
end
|
12
|
+
def to_hint = to_regexp.map(&:inspect).join(", ")
|
15
13
|
|
16
|
-
def to_regexp
|
17
|
-
list.map { |item| Regexp.new item }
|
18
|
-
end
|
14
|
+
def to_regexp = list.map { |item| Regexp.new item }
|
19
15
|
|
20
|
-
def empty?
|
21
|
-
list.empty?
|
22
|
-
end
|
16
|
+
def empty? = list.empty?
|
23
17
|
|
24
18
|
private
|
25
19
|
|
@@ -27,21 +27,13 @@ module Git
|
|
27
27
|
@matches = build_matches
|
28
28
|
end
|
29
29
|
|
30
|
-
def key
|
31
|
-
String matches["key"]
|
32
|
-
end
|
30
|
+
def key = String(matches["key"])
|
33
31
|
|
34
|
-
def name
|
35
|
-
String matches["name"]
|
36
|
-
end
|
32
|
+
def name = String(matches["name"])
|
37
33
|
|
38
|
-
def email
|
39
|
-
String(matches["email"]).delete_prefix("<").delete_suffix(">")
|
40
|
-
end
|
34
|
+
def email = String(matches["email"]).delete_prefix("<").delete_suffix(">")
|
41
35
|
|
42
|
-
def match?
|
43
|
-
text.match? key_pattern
|
44
|
-
end
|
36
|
+
def match? = text.match?(key_pattern)
|
45
37
|
|
46
38
|
private
|
47
39
|
|
data/lib/git/lint/rake/tasks.rb
CHANGED
@@ -21,9 +21,7 @@ module Git
|
|
21
21
|
|
22
22
|
attr_reader :commit, :analyzers
|
23
23
|
|
24
|
-
def report
|
25
|
-
analyzers.reduce("") { |report, analyzer| report + Style.new(analyzer).to_s }
|
26
|
-
end
|
24
|
+
def report = analyzers.reduce("") { |report, analyzer| report + Style.new(analyzer).to_s }
|
27
25
|
end
|
28
26
|
end
|
29
27
|
end
|
@@ -17,13 +17,9 @@ module Git
|
|
17
17
|
|
18
18
|
attr_reader :data
|
19
19
|
|
20
|
-
def label
|
21
|
-
"#{Line::DEFAULT_INDENT}Line #{number}: "
|
22
|
-
end
|
20
|
+
def label = "#{Line::DEFAULT_INDENT}Line #{number}: "
|
23
21
|
|
24
|
-
def paragraph
|
25
|
-
formatted_lines.join "\n"
|
26
|
-
end
|
22
|
+
def paragraph = formatted_lines.join("\n")
|
27
23
|
|
28
24
|
def formatted_lines
|
29
25
|
content.split("\n").map.with_index do |line, index|
|
@@ -31,17 +27,11 @@ module Git
|
|
31
27
|
end
|
32
28
|
end
|
33
29
|
|
34
|
-
def indent
|
35
|
-
" " * (label.length + 1)
|
36
|
-
end
|
30
|
+
def indent = " " * (label.length + 1)
|
37
31
|
|
38
|
-
def number
|
39
|
-
data.fetch :number
|
40
|
-
end
|
32
|
+
def number = data.fetch(:number)
|
41
33
|
|
42
|
-
def content
|
43
|
-
data.fetch :content
|
44
|
-
end
|
34
|
+
def content = data.fetch(:content)
|
45
35
|
end
|
46
36
|
end
|
47
37
|
end
|
@@ -9,21 +9,15 @@ module Git
|
|
9
9
|
@data = data
|
10
10
|
end
|
11
11
|
|
12
|
-
def to_s
|
13
|
-
%(#{Line::DEFAULT_INDENT}Line #{number}: "#{content}"\n)
|
14
|
-
end
|
12
|
+
def to_s = %(#{Line::DEFAULT_INDENT}Line #{number}: "#{content}"\n)
|
15
13
|
|
16
14
|
private
|
17
15
|
|
18
16
|
attr_reader :data
|
19
17
|
|
20
|
-
def number
|
21
|
-
data.fetch :number
|
22
|
-
end
|
18
|
+
def number = data.fetch(:number)
|
23
19
|
|
24
|
-
def content
|
25
|
-
data.fetch :content
|
26
|
-
end
|
20
|
+
def content = data.fetch(:content)
|
27
21
|
end
|
28
22
|
end
|
29
23
|
end
|
@@ -12,17 +12,13 @@ module Git
|
|
12
12
|
@pattern = pattern
|
13
13
|
end
|
14
14
|
|
15
|
-
def valid?
|
16
|
-
parts.all? { |name| String(name).match? pattern }
|
17
|
-
end
|
15
|
+
def valid? = parts.all? { |name| String(name).match? pattern }
|
18
16
|
|
19
17
|
private
|
20
18
|
|
21
19
|
attr_reader :text, :delimiter, :pattern
|
22
20
|
|
23
|
-
def parts
|
24
|
-
text.split delimiter
|
25
|
-
end
|
21
|
+
def parts = text.split(delimiter)
|
26
22
|
end
|
27
23
|
end
|
28
24
|
end
|
@@ -13,17 +13,13 @@ module Git
|
|
13
13
|
@minimum = minimum
|
14
14
|
end
|
15
15
|
|
16
|
-
def valid?
|
17
|
-
parts.size >= minimum && parts.all? { |name| !String(name).empty? }
|
18
|
-
end
|
16
|
+
def valid? = parts.size >= minimum && parts.all? { |name| !String(name).empty? }
|
19
17
|
|
20
18
|
private
|
21
19
|
|
22
20
|
attr_reader :text, :delimiter, :minimum
|
23
21
|
|
24
|
-
def parts
|
25
|
-
String(text).split delimiter
|
26
|
-
end
|
22
|
+
def parts = String(text).split(delimiter)
|
27
23
|
end
|
28
24
|
end
|
29
25
|
end
|
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: 2.2
|
4
|
+
version: 2.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
@@ -28,7 +28,7 @@ cert_chain:
|
|
28
28
|
lkHilIrX69jq8wMPpBhlaw2mRmeSL50Wv5u6xVBvOHhXFSP1crXM95vfLhLyRYod
|
29
29
|
W2A=
|
30
30
|
-----END CERTIFICATE-----
|
31
|
-
date: 2021-
|
31
|
+
date: 2021-08-09 00:00:00.000000000 Z
|
32
32
|
dependencies:
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: git_plus
|
@@ -36,14 +36,14 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '0.
|
39
|
+
version: '0.6'
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '0.
|
46
|
+
version: '0.6'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: pastel
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -186,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
186
|
- !ruby/object:Gem::Version
|
187
187
|
version: '0'
|
188
188
|
requirements: []
|
189
|
-
rubygems_version: 3.2.
|
189
|
+
rubygems_version: 3.2.25
|
190
190
|
signing_key:
|
191
191
|
specification_version: 4
|
192
192
|
summary: A command line interface for linting Git commits.
|
metadata.gz.sig
CHANGED
Binary file
|