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

Skip hook/command when commit message matches a pattern #780

Open
reitzig opened this issue Jul 22, 2024 · 2 comments
Open

Skip hook/command when commit message matches a pattern #780

reitzig opened this issue Jul 22, 2024 · 2 comments
Labels
feature request A new lefthook feature description

Comments

@reitzig
Copy link

reitzig commented Jul 22, 2024

⚡ Summary

Allow to skip a hook (or individual command) if the commit message matches a certain pattern.

Value

I like using cog verify (cf. cocogitto/cocogitto) as part of a commit-msg hook. I also like creating fixup commits (in IDEA, if that matters) which end up vanishing after rebasing with autosquash.

Sadly, the two do not mix well: cocogitto forbids the ephemeral commit messages of such commits, as they don't conform to conventional commits.

What I would like is to configure lefthook to ignore fixup commits:

commit-msg:
  skip:
    - ref: "wip/*"
    - msg: "^fixup! "
  commands:
    cog:
      run: cog verify --file {1}

Behavior and configuration changes

The change seems additive to me.

@reitzig reitzig added the feature request A new lefthook feature description label Jul 22, 2024
@reitzig
Copy link
Author

reitzig commented Jul 22, 2024

FWIW: cocogitto/cocogitto#403

Either feature fixes my use case, but I do think that this proposal has merit in its own right for lefthook. Users may use different tools to enforce conventional commits!

@reitzig
Copy link
Author

reitzig commented Aug 2, 2024

Workaround:

commit-msg:
  skip:
    - ref: "wip/*"
  commands:
    cog:
      run: sh -c "if grep -qv '^fixup!' {1}; then cog verify --file {1}; fi"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request A new lefthook feature description
Projects
None yet
Development

No branches or pull requests

1 participant