Skip to content

✨ Add pre-commit hook#221

Open
derekrgreene wants to merge 2 commits intoGDQuest:mainfrom
derekrgreene:main
Open

✨ Add pre-commit hook#221
derekrgreene wants to merge 2 commits intoGDQuest:mainfrom
derekrgreene:main

Conversation

@derekrgreene
Copy link
Copy Markdown

@derekrgreene derekrgreene commented Apr 12, 2026

Please check if the PR fulfills these requirements:

  • The commit message follows our guidelines.
  • For bug fixes and features:
    • You tested the changes.

Related issue (if applicable): #141

What kind of change does this PR introduce?

  • New feature

Does this PR introduce a breaking change?

  • No

New feature or change

What is the current behavior?

There is no standard Git pre-commit hook, so users who want to use gdscript-formatter as a pre-commit hook have to configure it manually.

What is the new behavior?

Users can copy this pre-commit hook into their .git/hooks/pre-commit directory to automatically format .gd files prior to each Git commit.

Other information

Fixes #141

@NathanLovato
Copy link
Copy Markdown
Contributor

Okay, so from what I gather, this pre-commit thing is actually a Python framework that people have to install just to be able to reference hooks from a repository, right? If so, could you please briefly document the setup that people need to go through to actually use this?

A feature like this is a bit niche, I think, and even more so if people need to already know about the specific tool and have it installed beforehand.

I would also personally start by giving them an example of how to use an actual standard Git hook, which takes minutes to set up, and then mention that there is this convenience feature on top of that for those who want it (but it's not strictly necessary, it's a small extra convenience).

@derekrgreene
Copy link
Copy Markdown
Author

Thanks for taking a look at this @NathanLovato!

A feature like this is a bit niche, I think, and even more so if people need to already know about the specific tool and have it installed beforehand.

This is a great point and I have refactored in favor of a simple POSIX standard Git hook!

I would also personally start by giving them an example of how to use an actual standard Git hook, which takes minutes to set up

I added an example of how to use the standard Git hook to the README and instructions for copying the hook to the correct directory .git/hooks/pre-commit.

I wasn't sure about the best place to explain the hook in the README, so let me know if you think it has a better home further down the file, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a pre-commit hook to easily install and use the formatter as a commit hook

2 participants