-
Notifications
You must be signed in to change notification settings - Fork 32
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
github: formatting: add check on push and pull-request #810
Conversation
@kkanas will this pre-commit hook make git fail when committing anything that invalidates the rules? Sorry im new to these hooks and trying to see the differences/advantages in them. |
Hi Yes this should fail when you commit anything that invalidates the rules.
So if we ran this on server we should have build failures when pull request is filed when those rules are not uphold. Now the how we want to run pre-commit, either in way of showing violation |
AhmedBM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
See my other reply. |
3aebc67
to
6e1badf
Compare
Add pre-commit to allow local check before commit. This requires installing pre-commit on local machine. Flow to install and check/debug: pip install pre-commit pre-commit install \# run pre-commit on single file file_to_check.txt pre-commit run --verbose --files file_to_check.txt \# run pre-commit on all files pre-commit run --verbose --all-files Rules for pre-commit are in .pre-commit-config.yaml: Currently rules are: mixed-line-ending: args: ['--fix', 'no'] Reports rule and stops on when file has mixed line endings will run on all files in repository excluding files ending with .cmd mixed-line-ending: args: ['--fix', 'crlf'] files: '\.cmd$' Will *automatically* correct lf to crlf on files ending with .cmd To uphold rules on server new github workflow is added that will execute pre-commit run --all-files Lastly I changed .gitattributes to also force crlf in cmd files. Signed-off-by: Krzysztof Kanas <[email protected]>
This commit was created by running: python3 -m pre_commit run --all-files Then and adding all the files git status --short |awk '$1 ~ /M/{print $2}'| xargs -I {} git add -f {} This will fix formmating by applying rules in .pre-commit-config.yaml If you would like to review changes file by fine you can take advantage of shell script: for f in $(git diff --no-prefix --name-only @~); do git diff @~..@ $f; done Signed-off-by: Krzysztof Kanas <[email protected]>
6e1badf
to
c995896
Compare
Add missing file to follow to formatting rules Signed-off-by: Krzysztof Kanas <[email protected]>
Rebased content and added exclude for devops/docker/.*/Dockerfile in #850 |
Add pre-commit to allow local check before commit. This requires installing pre-commit on local machine. Flow to install and check/debug:
pip install pre-commit
pre-commit install
# run pre-commit on single file file_to_check.txt pre-commit run --verbose --files file_to_check.txt # run pre-commit on all files
pre-commit run --verbose --all-files
Rules for pre-commit are in .pre-commit-config.yaml: Currently rules are:
check-added-large-files:
Will stop commit if large files to the repo
mixed-line-ending:
args: ['--fix', 'no']
Reports rule and stops on when file has mixed line endings
will run on all files in repository excluding files ending with .cmd
mixed-line-ending:
args: ['--fix', 'crlf']
files: '.cmd$'
Will automatically correct lf to crlf on files ending with .cmd
To uphold rules on server new github workflow is added that will execute pre-commit run --all-files
Lastly I changed .gitattributes to also force crlf in cmd files.
Description
Describe your changes in as much detail as possible. Provide a link/reference to the issue solved with this request if any.
Checklist
main
branch prior to this PR submission.main
branch.