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

Pre push hook to ensure code is formatted on upload #2085

Merged
merged 5 commits into from Feb 13, 2022

Conversation

baronfel
Copy link
Contributor

Feel free to not take this, this is a little experiment.

I added a git hook that fires before commits are pushed to a repo that invokes the CheckFormat target. If that target fails, the push fails.

In order for this to work, by default the hook script would have to live in the .git/hooks directory, but this directory isn't sharable/tracked in git. Therefore, I made a new directory to hold the hooks, and added a build script target that can be used to set up this kind of repo-local git config (since the .git/config file can't be shared for the same reason!). One other use of this target might be to set the .git-blame-ignore-revs file configuration, for example.

What do you think? I would imagine if you like this I'd need to update the README as well.

Copy link
Contributor

@nojaf nojaf left a comment

Choose a reason for hiding this comment

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

Thanks Chet! I'm ok with having this. Some minor nits.

build.fsx Outdated Show resolved Hide resolved
@nojaf nojaf merged commit afc97e1 into fsprojects:master Feb 13, 2022
@baronfel baronfel deleted the pre-push-hook branch February 13, 2022 16:09
jindraivanek pushed a commit to jindraivanek/fantomas that referenced this pull request Mar 30, 2022
* Add a prepush hook to ensure that formatting is run

* fix reporting

* formatting after change, proof that the prepush hook works

* add documentation and samples to prepush script

* Document the need to install/configure git hooks
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.

None yet

2 participants