-
-
Notifications
You must be signed in to change notification settings - Fork 53
feat: support co-authorship lines in body #130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: support co-authorship lines in body #130
Conversation
|
@targos strangely, I can't tag people for review O.o cc @joyeecheung |
lib/rules/line-length.js
Outdated
| // Skip lines with URLs. | ||
| if (/https?:\/\//.test(line)) { continue } | ||
| // Skip co-authorship. | ||
| if (line.startsWith('Co-Authored-By')) { continue } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be more useful to properly validate the format (i.e. flag Co-authored-by: Author Name But No Email, etc.)
Also, could you add tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Email is what causes the issue though
Co-authored-by: Michaël Zasso <targos@protonmail.com>
per existing `co-authored-by-is-trailer` rule's regex
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
test/rules/line-length.js
Outdated
| message: ` | ||
| fixup!: apply case-insensitive suggestion | ||
| Co-authored-by: Michaël Zasso <37011812+targos@users.noreply.github.com> | ||
| ` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a good test, it passes without your patch because of the leading spaces
| message: ` | |
| fixup!: apply case-insensitive suggestion | |
| Co-authored-by: Michaël Zasso <37011812+targos@users.noreply.github.com> | |
| ` | |
| message: [ | |
| 'fixup!: apply case-insensitive suggestion', | |
| 'Co-authored-by: Michaël Zasso <37011812+targos@users.noreply.github.com>', | |
| ].join('\n') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should fail though, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A good regression test fails without the patch, and passes with it. Currently the test passes with and without your patch. If we want a good regression test (we do), we want one that fails without the patch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I mean it seems suspicious that it isn't failing, which would suggest the implementation is bugged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I discovered why the test is suspiciously passing:
core-validate-commit/lib/rules/line-length.js
Lines 32 to 33 in 39b93a3
| // Skip quoted lines, e.g. for original commit messages of V8 backports. | |
| if (line.startsWith(' ')) { continue } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(@aduh95 I don't know what to do about it)
| // Skip lines with URLs. | ||
| if (/https?:\/\//.test(line)) { continue } | ||
| // Skip co-authorship. | ||
| if (/^co-authored-by:/i.test(line)) { continue } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I'm not sure it's worth doing, but we could have a shared util to avoid duplicating the regex
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 I think if we need it in a third place, then it's worth having a shared util.
This comment was marked as off-topic.
This comment was marked as off-topic.
73cd024 to
8016e6a
Compare
8016e6a to
f05715d
Compare
| const overlongMessage = `fixup!: apply case-insensitive suggestion | ||
| Co-authored-by: Michaël Zasso <37011812+targos@users.noreply.github.com>` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const overlongMessage = `fixup!: apply case-insensitive suggestion | |
| Co-authored-by: Michaël Zasso <37011812+targos@users.noreply.github.com>` | |
| const overlongMessage = [ | |
| 'fixup!: apply case-insensitive suggestion', | |
| 'Co-authored-by Michaël Zasso <37011812+targos@users.noreply.github.com>' | |
| ].join('\n') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test-case is asserting it correctly errors. Your proposed change would cause it to not error (and then it's the same case as the other one added in this PR).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would it not error? Mind the lack of :, it should error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The (lack of) leading spaces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand how relevant are the leading spaces for the code you're adding, it feels much more likely to me that someone would forgot to add / remove by mistake the colon rather than add leading spaces. Anyway, I'm just trying to suggest something to help you get a green CI, feel free to fix the test another way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You requested this test-case though. If you don't want it, I'll just remove it and CI will be green.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I did, removing it sounds good to me
Co-authorship lines contain an email address which is very likely longer than 72 characters (any github-anonymised email address), which cannot be broken across multiple lines.