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 pre-commit hooks to automatically format code on git commit #18

Merged
merged 2 commits into from
Jul 1, 2024

Conversation

jordan-gillard
Copy link
Contributor

This PR adds pre-commit, a Python library for configuring and running git hooks.

I added configuration to run the black code formatter automatically whenever a user runs git commit. It will only run on Git staged files. The pre-commit config also has checks for yaml files, adding a newline to the end of files, and removing trailing whitespaces from lines. I also ran these hooks on the entire code base, which applied minor formatting changes.

README.md Outdated
@@ -105,6 +105,9 @@ pip install poetry
# Install dependencies
poetry install

# Setup pre-commit hooks
pre-commit install
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would this be better as:

poetry run pre-commit install

Or should we poetry shell before or something else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! Ill take care of that in my next commit.

Copy link
Collaborator

Choose a reason for hiding this comment

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

To double check, on the other PR?

Also, I've really appreciated this PR (and think I'll like #19 too) - I'm not a software engineer, but am always keen to learn more! These have been tremendously educational for me, so thank you 🙌

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the instruction here: 3d41505

There might be a merge conflict in the other PR's README.md after this one goes in. If so it'll be a simple fix :)

I'm not a software engineer, but am always keen to learn more! These have been tremendously educational for me, so thank you 🙌

Awww, brooo 😊 You are absolutely a software engineer!

I'm glad you find my code helpful! I'm happy to contribute and spread some knowledge.

@GalenReich GalenReich merged commit 9d5bfcf into bellingcat:main Jul 1, 2024
@jordan-gillard jordan-gillard deleted the add-pre-commit-hooks branch July 5, 2024 17:19
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.

2 participants