Skip to content
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

Ignore leading comments and empty lines when parsing commit via stdin #114

Closed
dpc opened this issue Feb 3, 2023 · 5 comments
Closed

Ignore leading comments and empty lines when parsing commit via stdin #114

dpc opened this issue Feb 3, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@dpc
Copy link

dpc commented Feb 3, 2023

Is your feature request related to a problem? Please describe.
I just implemented commit-msg git hook linting with convco: https://github.com/fedimint/fedimint/pull/1573/files

I had to do some extra work, because the commit message can actually be prefixed with newlines and comment lines which git will happily throw away before turning the whole message into a actual commit, but convco will complain about.

Describe the solution you'd like
Not sure if should be the default behavior altogether, or just when parsing from stdin, or maybe an option, but it would be easier if convco could take care of it (ignore leading newlines and comments).

@dpc dpc added the enhancement New feature or request label Feb 3, 2023
@hdevalke
Copy link
Collaborator

hdevalke commented Feb 3, 2023

convco does this in the commit subcommand. And it looks like this is documented in git:

The commit-msg hook takes one parameter, which again is the path to a temporary file that contains the commit message written by the developer.

as this repository follows conventional commits, comments and extra newlines should be seen as an error, so i think the best way is to add a flag --ignore-newlines-and-comments

@hdevalke
Copy link
Collaborator

hdevalke commented Feb 3, 2023

The behaviour of git can depend on the --cleanup mode.

@dpc
Copy link
Author

dpc commented Feb 3, 2023

-ignore-newlines-and-comments gets long and without "leading" a bit incorrect, so maybe --cleanup instead as well? :D

hdevalke added a commit that referenced this issue Feb 6, 2023
Removes leading and trailing newlines and comments and trailing whitespace from the commit message read from stdin. It also colapses multiple empty lines into one.

Refs: #114
@hdevalke
Copy link
Collaborator

hdevalke commented Feb 6, 2023

I used --strip other modes can be implemented later.

hdevalke added a commit that referenced this issue Feb 7, 2023
Removes leading and trailing newlines and comments and trailing whitespace from the commit message read from stdin. It also colapses multiple empty lines into one.

Refs: #114
hdevalke added a commit that referenced this issue Feb 7, 2023
Removes leading and trailing newlines and comments and trailing whitespace from the commit message read from stdin. It also colapses multiple empty lines into one.

Refs: #114
@hdevalke
Copy link
Collaborator

hdevalke commented Feb 9, 2023

fixed in #116

@hdevalke hdevalke closed this as completed Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants