-
Notifications
You must be signed in to change notification settings - Fork 29
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
base: main
Are you sure you want to change the base?
Conversation
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. Signed-off-by: Krzysztof Kanas <[email protected]>
* text=auto | ||
*.cmd text eol=crlf |
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.
)$ | ||
- id: mixed-line-ending | ||
args: ['--fix', 'crlf'] | ||
files: '\.cmd$' |
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.
args: ['--fix', 'no'] | ||
exclude: | | ||
(?x)( | ||
.*\.cmd |
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.
)$ | ||
- id: mixed-line-ending | ||
args: ['--fix', 'crlf'] | ||
files: '\.cmd$' |
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.
Can we achieve the same all via .gitattributes? We can add there exclusions, default conversion, etc.
* text=auto |
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.
Can we add here more, like for example:
# Set the default behavior to automatically normalize line endings.
* text=auto
# Explicitly declare text files you want to always be normalized and converted to LF upon checkout.
*.c text eol=lf
*.cpp text eol=lf
*.h text eol=lf
*.txt text eol=lf
*.json text eol=lf
*.yml text eol=lf
*.md text eol=lf
# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
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.