This article focuses on documenting my own process and some of the issues I encountered when configuring the COMMIT specification
The problem
However, in daily work,git commit information is simply written or even carelessly written, which is undoubtedly not friendly for project management and maintenance.
purpose
Configure git commit verification specifications to form a standard Commit log to facilitate backtracking, locating problems, and installing the commit verification tool
yarn add @commitlint/config-conventional @commitlint/cli -D
Copy the code
Add validation format configuration files to the root directory. Create a new file commitlint.config.js to add content
module.exports = {extends: ['@commitlint/config-conventional']}
Copy the code
In order to automatically check our input messages with CommitLint at Git commit time, we also need to install -husky.
yarn add husky -D
npx husky install
npx husky add .husky/commit-msg 'npx --no-install commitlint --edit "$1"'
Copy the code
Now let’s test the commitGit commit -m
Failure to comply with submission specifications is reported and the reason for the error is displayed.
Try standardizing submissions belowGit commit -m 'test(app.vue):
All right, now we’re all configured
Submit specifications
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
Copy the code
The Header section contains three fields: Type (required), scope (optional), and Subject (required)
type
Submission type (mandatory),Feat: the new featurefix: fix the bugdocs: Only modified the document, such as readme.mdstyle: Only format changes, such as commas, indents, Spaces, etc. Do not change the code logic.refactor: Code refactoring, no new features or bug fixesperf: Optimization related, such as improving performance and user experience.test: Test cases, including unit tests and integration tests.chore: Change the build process, or add dependent libraries, tools, etc.revert: Version rollbackbuild: Package build CICopy the code
scope
Range of influence (optional) Multiple can be used/
.\
..
separatedsubject
Submit a short description (required)
Body
- The detailed description of the commit modification can be divided into multiple lines
Footer
BREAKING CHANGE
Major changeIssue
Close or fix previous bugs
commitizen
You need to manually enter a command for each submission, which is easy to indicate that the submission fails. Commitizen is an interactive tool for creating submission information to help generate submission documents without formatting errors
The installation
yarn add commitizen -D
/ / install cz - but - changelog
// Save it to package.json dependencies or devDependencies
// Add the config Commitizen configuration to the package.json root directory, as shown below
npx commitizen init cz-conventional-changelog --save-dev --save-exact
/ / configuration
scripts: {
commit: cz
}
Copy the code
Try using YARN COMMIT
If an error occurs, remove node_modules and install again