-
Notifications
You must be signed in to change notification settings - Fork 1
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
Baseline pre-commit hooks and Git files #1
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add a .gitattributes file to the repository, to assign attributes to files and folders in the repository. This file was taken from gitattributes/gitattributes@5a965d3. This specific .gitattributes file, amongst other things: - auto-detects text files and performs LF normalization - explicitly declares common files as either text and binary - explicitly declares known OS-specific files as ending with CRLF or LF - converts complex file types to text (doc, pdf, etc) before a diff - ignore the .gitignore and .gitattribute files when exporting the repo A guide on the .gitignore file's capabilities can be found on David Laing's blog, at https://bit.ly/36QX6UD As that repository is licensed under MIT, the repo's license notice was added to the top of the file as a comment.
Add a .gitignore file, generated at www.gitignore.io. This particular gitignore prevents tracking for common files generated by: - Windows - Linux - Visual Studio Code The generated file can be viewed and modified by navigating to https://bit.ly/37SkQcr
Add support for pre-commit (www.pre-commit.com) to the project repository, to manage the project's Git hooks. With this commits, the following pre-commit hooks are introduced, from the pre-commit/pre-commit-hooks repository. - check-yaml - end-of-file-fixer - trailing-whitespace - check-case-conflict - detect-private-key - mixed-line-ending
Add support for commitlint (https://commitlint.js.org) to the repository, enforcing the Conventional Commit specification for Git commit messages (https://www.conventionalcommits.org). The pre-commit repo for the hook can be found at alessandrojcm/commitlint-pre-commit-hook The Git hook must be installed before use by running the following command: pre-commit install --hook-type commit-msg
Add a Git hook to run Prettier, an opiniated code formatter, to re-format staged files at commit time, standardizing formatting across files and repositories. Details about Prettier can be found at https://prettier.io/ Details about Prettier with pre-commit hooks can be found at https://bit.ly/38qPdGZ
🎉 This PR is included in version 1.0.0-develop.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 1.0.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
ShahradR
added a commit
that referenced
this pull request
Oct 21, 2022
Add documentation for the baseline pre-commit hooks introduced in the ShahradR/git-template#GH-1 pull request to the docs/ folder, and serve it using MkDocs rather than pointing users to the pull request.
ShahradR
added a commit
that referenced
this pull request
Dec 5, 2022
Update the sed command when deleting lines from the .pre-commit-config file with the correct syntax. Without adding `d` to the line number, the sed invocation fails with the following error message: `sed: -e expression #1, char 2: unknown command: `;'`
ShahradR
added a commit
that referenced
this pull request
Dec 5, 2022
Update the sed command when deleting lines from the .pre-commit-config file with the correct syntax. Without adding `d` to the line number, the sed invocation fails with the following error message: `sed: -e expression #1, char 2: unknown command: ';'`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Git dotfiles
This pull request introduces baseline
.gitignore
and.gitattributes
files..gitignore
The
.gitignore
file has been generated on gitignore.io, and ignores common files generated by:.gitattributes
The
.gitattributes
file was introduced to manage file endings on files pushed to the repository. We used theCommon.gitattributes
file from gitattributes/gitattributes@5a965d3 as a baseline, which sets many other attributes, including appropriate line endings for common file types. Details on the attributes set by this file can be found in commit 18aa76fpre-commit
This pull request introduces pre-commit as a Git hook management tool.
Specifically, this PR introduces eight hooks, listed below. These hooks are to be used in all repositories, and act as a baseline set of checks before commits are pushed upstream. These hooks are:
The sections below outline the different hooks introduced in this pull request.
Check Yaml
This hook checks
.yaml
files for valid syntax, using the ruamel.yaml YAML loader/dumper for Python.Fix End of Files
UNIX applications typically expect a new line at the end of every file (some examples are the GNU diff and sort tools – see this StackExchange question for a detailed explanation). This hook ensures that all files pushed to the repository end with a new line.
Trim Trailing Whitespace
This hook removes invisible whitespace characters at the end of a line.
Check for case conflicts
File names in Linux operating systems are case-sensitive – the files
FILE.txt
andfile.txt
are considered as two distinct files. Windows files, however, are case-insensitive.To prevent conflicts between the two operating systems, this hook ensures that no two files have the same name, regardless of the case used.
Detect Private Key
This hook detects private keys and other secrets that might have been inadvertantly staged, and blocks the commit.
Mixed line endings
This hook flags files that contain both Windows (CRLF) and Linux (LF) file endings.
Prettier
This hook runs the Prettier code formatter on all files before committing.
commitlint
This commit-msg hook verifies that commit messages follow the Conventional Commits specification. A full list of checks can be found here.