Skip to content

🔧 Repository: backstage/community-plugins #7667

@bplaxco

Description

@bplaxco

📜 Description

Hey folks 👋

I'm filing an issue here to see if we can make a small change to the .husky/pre-commit script in this repository to allow it to optionally support git hooks that were copied in from the git init template dir.

It'd be a three line addition at the end of the file and I don't expect it should cause issues for existing contributors. Or at least that's the hope that it can be added in a non-impactful way.

Here's the snippet that'd go at the very end of .husky/pre-commit:

# support local pre-commit hooks
if [ -x .git/hooks/pre-commit ]; then
  exec .git/hooks/pre-commit
fi

👍 Expected behavior

It would be desirable to also run a pre-commit hook located at .git/hooks/pre-commit after running the other hooks defined in the script, but only if .git/hooks/pre-commit exists and is executable.

👎 Current Behavior

It currently just runs the husky hooks (which is not a flaw, just not desirable for one of our use cases).

👟 Reproduction steps

  1. Add a custom pre-commit hook in .git/hooks/pre-commit
  2. Set up the repo for normal contrib (i.e. in the way that sets up husky)
  3. See that git ignores the default location for the hook and favors the husky hook instead

📃 Provide the context for the Bug.

The main reason for the change is we use a pre-commit hook to detect leaks during commits. This would provide a way for that process to continue and be transparent to the work in the repo here. And also if folks have other pre-commit hooks they want to use locally but not make it an official part of backstage's repos, it'd be supported as well 👍

👀 Have you spent some time to check if this bug has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Are you willing to submit PR?

Yes I am willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions