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 hook #40

Merged
merged 3 commits into from
Sep 13, 2023
Merged

Add pre-commit hook #40

merged 3 commits into from
Sep 13, 2023

Conversation

ryanhiebert
Copy link
Owner

@ryanhiebert ryanhiebert commented Sep 13, 2023

Check the migrations files in the current repository and ensure that they all have a safe property defined. While we can think of easy ways to break this implementation, for all the use-cases I've had this covers it quite nicely so I think it's worth merging even if its rough.

Tim Schilling put an initial sketch of this in #39 and I was able to modify it for use in a precommit hook without difficulty. The modifications were made to tailor it to the environment of pre-commit, where file names are passed to the command as arguments. This allows pre-commit to only need to run the checks incrementally for the affected files for new commits.

Fix #39

Check the migrations files in the current repository and
ensure that they all have a `safe` property defined.
While we can think of easy ways to break this implementation,
for all the use-cases I've had this covers it quite nicely
so I think it's worth merging even if its rough.

Tim Schilling put an initial sketch of this in
#39
and I was able to modify it for use in a precommit hook
without difficulty. The modifications were made to tailor
it to the environment of pre-commit, where file names are
passed to the command as arguments. This allows pre-commit
to only need to run the checks incrementally for the affected
files for new commits.

Co-authored-by: Tim Schilling <schillingt@better-simple.com>
@codecov
Copy link

codecov bot commented Sep 13, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (e4e5300) 100.00% compared to head (0294724) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #40   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            3         4    +1     
  Lines           71        90   +19     
  Branches        24        29    +5     
=========================================
+ Hits            71        90   +19     
Files Changed Coverage Δ
src/django_safemigrate/check.py 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@tim-schilling tim-schilling left a comment

Choose a reason for hiding this comment

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

Could we add how to install this to the README? It will help adoption from other folks.

@ryanhiebert
Copy link
Owner Author

Yes, although because the configuration has a release version in it, we'll have to update that version when we do releases. Do you think that's acceptable?

@tim-schilling
Copy link
Collaborator

Yeah that seems reasonable. I should probably document that whole process anyway.

@ryanhiebert
Copy link
Owner Author

OK, I updated it, but I put a commit hash. Would you like me to go ahead and prepare a release?

@ryanhiebert
Copy link
Owner Author

Ug, I got my wires crossed. I have it as described locally, but the rst linter isn't happy and I need to fix it. I'll plan to prepare a release unless you say you prefer I not.

@tim-schilling
Copy link
Collaborator

That should be fine.

Copy link
Collaborator

@tim-schilling tim-schilling left a comment

Choose a reason for hiding this comment

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

Looks good! Thank you for pushing this forward

@ryanhiebert ryanhiebert merged commit afb27aa into main Sep 13, 2023
@ryanhiebert ryanhiebert deleted the precommit branch September 13, 2023 19:53
@ryanhiebert
Copy link
Owner Author

Alright, I've tagged the release. It actually probably doesn't matter if it gets to PyPI since it's for the pre-commit hook, which is directly on the repository. It's already working well for me.

But if you do want to cut the release to match the tag, you'll need to do it. I no longer have maintainer access to the package on PyPI.

@tim-schilling
Copy link
Collaborator

Done!

@ryanhiebert
Copy link
Owner Author

thank you!

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.

Create a standard pre-commit hook to require safe attribute
2 participants