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

Add a commit or manual stage to pre-commit hook config #192

Merged

Conversation

guillaumelambert
Copy link
Contributor

gitlint cannot be run easily via pre-commit inside a CI without pre-commit configuration for the commit stage

#191

@guillaumelambert
Copy link
Contributor Author

@jorisroovers hello
I haven't received any feedback in almost 6 months and I don't think the modification proposed here is very complex.
Please can anyone review this commit or the associated issue ? I'd be happy to give more details if needed.
Kind Regards
Guillaume

@jorisroovers
Copy link
Owner

Sorry, stretched pretty thin. Don't know when I'll get to reviewing this - would need to try it out.

@guillaumelambert
Copy link
Contributor Author

Sorry, stretched pretty thin. Don't know when I'll get to reviewing this - would need to try it out.

Thanks for the answer. You're apologized. Cheer up!

@@ -4,3 +4,10 @@
entry: gitlint
args: [--staged, --msg-filename]
stages: [commit-msg]
- id: gitlint0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asottile do you have a better idea of how to do this? I don't think this would work well for most users:

  • I suspect most people want pre-commit to install the commit-msg hook locally
  • In CI, most people will want to run gitlint to check the commit message(s) in the pull request content and will want pre-commit to do that
  • The arguments must differ between stages of the commit lifecycle

At the very least the id here should be gitcommit-postcommit (or something more descriptive than 0).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sigmavirus24 thanks for the feedback
I have no objection to change the id here.
That's correct. It is the only solution that I found to satisfy the requirements to make it work (at least on my side) with both CI and hooks. I am open to any other suggestion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah this shouldn't be needed at all. you can follow this procedure:

  1. write out each commit message to files (left to the reader)
  2. xargs -n1 pre-commit --hook-stage commit-msg --commit-msg-filename

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asottile
The problem with "pre-commit --hook-stage commit-msg --commit-msg-filename" is that it does not currently perform any check if the git environment is not configured, what appends in most CI...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no sorry, you're incorrect about this -- I created it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can reopen this one, I think

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sigmavirus24 Thanks. I cannot do it by myself since only repo committers and maintainers are allowed to do this. Can you take care of it ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sigmavirus thanks for reopening the PR. I've pushed the update. (I would have liked to change my source branch but surprisingly this does not appear to be supported by github so I had to stick with the old branch naming that is a bit confusing now...). Hope this helps.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello

I didn't receive any feedback since the last PR modification.
And I think it covers all or almost all previous feedback received.
Just let me know if there is still anything blocking its approval.

Kind Regards
Guillaume

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems a few commits were integrated in the main branch meanwhile. So I rebased this.
@sigmavirus24 @jorisroovers Just let me know if there is something more I can do.

@guillaumelambert guillaumelambert changed the title Add a commit stage to pre-commit hook config Add a commit or manual stage to pre-commit hook config Jan 31, 2022
@sigmavirus24 sigmavirus24 reopened this Feb 1, 2022
@jorisroovers jorisroovers self-assigned this Oct 25, 2022
@jorisroovers
Copy link
Owner

I apologize for not getting to this earlier. After reading the discussion, I think this makes sense. I just rebased the PR to latest main. I'm out of time today to try this out, but this item is at the top of my list now - will try it out soon.

@jorisroovers jorisroovers added this to the 0.18.0 milestone Nov 11, 2022
Clarifying how to set it up and configure it.
@jorisroovers
Copy link
Owner

Tested this, looks good. Added some docs as well. Merging.

Thanks for contributing and your patience :-)

@jorisroovers jorisroovers merged commit 7d9981a into jorisroovers:main Nov 11, 2022
@KSmanis
Copy link

KSmanis commented Nov 11, 2022

Is there an ETA on a release containing this changeset?

@jorisroovers
Copy link
Owner

This was the last planned change for v0.18.0. I expect 0.18.0 to go out next week 🤞

AFAIK, you don't need to wait though. If you specify rev: 7d9981a72d0719ff530c24b60b18f4cbb0cd5edc in your pre-commit config you should be able to use this today.

@KSmanis
Copy link

KSmanis commented Nov 11, 2022

This was the last planned change for v0.18.0. I expect 0.18.0 to go out next week crossed_fingers

Looking forward to it!

AFAIK, you don't need to wait though. If you specify rev: 7d9981a72d0719ff530c24b60b18f4cbb0cd5edc in your pre-commit config you should be able to use this today.

Indeed, but my hook versions are managed by Renovate bot, which only supports GitHub tags as a data source. I don't think it would play nice (if at all) with a fixed rev; at least not without jumping through hoops.

odl-github pushed a commit to opendaylight/transportpce that referenced this pull request Nov 17, 2022
- update pre-commit repo revision
- use new gitlint-ci pre-commit profile
  jorisroovers/gitlint#192
- update pre-commit configuration accordingly
  especially remove gitlint profile from envlist
  since it is now supersed by gitlint-ci pre-commit profile

Signed-off-by: guillaume.lambert <guillaume.lambert@orange.com>
Change-Id: I0984526059a4f869099c32f22909618fd294c549
odl-github pushed a commit to opendaylight/transportpce that referenced this pull request Dec 28, 2022
- update pre-commit repo revision
- use new gitlint-ci pre-commit profile
  jorisroovers/gitlint#192
- update pre-commit configuration accordingly
  especially remove gitlint profile from envlist
  since it is now supersed by gitlint-ci pre-commit profile

Signed-off-by: guillaume.lambert <guillaume.lambert@orange.com>
Change-Id: I0984526059a4f869099c32f22909618fd294c549
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 0.18.0
Development

Successfully merging this pull request may close these issues.

None yet

6 participants