Skip to content

Commit c75aede

Browse files
committed
fix: name author.name and author.email in the CC017 advice
A tool named in author.name or author.email stays the author after user.name and user.email are set and GIT_AUTHOR_* are unset, because git reads the author.* pair first. The advice for a message that is not a commit yet now lists them among the settings to unset.
1 parent 927ecce commit c75aede

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

‎commit_check/engine.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,10 +1731,13 @@ def validate(self, context: ValidationContext) -> ValidationResult:
17311731
# would rewrite the one before it, and --reset-author on its own
17321732
# records this same identity again. The Action pipes existing
17331733
# pull request commits this way too, hence the last clause.
1734+
# author.name and author.email outrank user.name and user.email,
1735+
# so a tool named there survives setting the user.* pair alone.
17341736
suggest = (
17351737
"Commit as yourself: set git config user.name and user.email "
1736-
"to your own, and unset GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL "
1737-
"if a tool set them; a commit that already exists then needs "
1738+
"to your own, and unset author.name, author.email, "
1739+
"GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL if a tool set them; a "
1740+
"commit that already exists then needs "
17381741
"git commit --amend --reset-author"
17391742
)
17401743
else:

‎tests/engine_test.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3665,8 +3665,9 @@ def test_a_message_not_yet_committed_is_not_told_to_amend(self, context):
36653665
_result, validator, _ = self._run(self.JULES, context=context)
36663666
assert validator._last_failure["suggest"] == (
36673667
"Commit as yourself: set git config user.name and user.email "
3668-
"to your own, and unset GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL "
3669-
"if a tool set them; a commit that already exists then needs "
3668+
"to your own, and unset author.name, author.email, "
3669+
"GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL if a tool set them; a "
3670+
"commit that already exists then needs "
36703671
"git commit --amend --reset-author"
36713672
)
36723673

0 commit comments

Comments
 (0)