Branch management

As shown: The Master branch is only used to store online urgent bugs. The hot-fix branch is developed on the Dev branch. Minor test bugs can also be fixed on the dev branch. Dev -${devName}

Git Commit Message specification

Use Angular’s Commit Message format.

A commit message format

Each COMMIT message contains header,body, and footer on a single line with no more than 100 characters each. Header consists of Type, scope and Subject. The header must be written. The scope of the header is optional.

<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
Copy the code

Revert

If commit is used to undo a previous COMMIT, start with Revert:, followed by the headers of the revoked commit. The body should say: this reverts commit. Hash is the hash value of the commit that was revoked. This format can also be generated automatically by the Git Revert command.

Type

Must be one of the following:

  • Feat: New Feature
  • Fix: Fixes bugs
  • Docs: Document modification
  • Style: changes that do not affect the meaning of the code (e.g., white-space; Formatting, etc.)
  • Refactor: refactoring (i.e. code changes that are not new features or bug fixes)
  • Perf: Changes to improve performance
  • Test: Adds or modifies tests
  • Chore: Changes to the build process or helper

Scope

Scope is used to specify the scope of commit modifications, such as data layer, control layer, view layer,route, Component, utils, Build, and so on. If the modification affects multiple areas, use asterisk (*).

Subject

Subject is a brief description of the modification:

  • Use the imperative mood, simple present tense.
  • Lowercase letter
  • Don’t use periods at the end of sentences

Body

Use the imperative mood, simple present tense. In addition, the body needs to include the reason for the change and the difference from the previous version.

Footer

Any information about Breaking changes or closing an issue can be written in the Footer. Breaking Changes needs to start with Breaking CHANGE:.

My two submission records are as follows:

commit 9fb447d73c637cfa128b57a84d95dc72bb14412b (HEAD -> master) Author: zhongjx <[email protected]> Date: Wed Dec 26 18:22:53 2018 +0800 refactor(*): Using prettier formatting code using eslint + prettier eslint + replacing an specification commit a4a5e9259d5dd4f5f4d3d16fea3392df2a877ee1 (origin/master) Author: Zhongjx <[email protected]> Date: Tue Nov 20 09:49:27 2018 +0800 chore: Add commit MSG format requirementsCopy the code

For more examples, see commits in angular.js

Configure use in Webpack

The installation

npm i --save-dev @commitlint/cli @commitlint/config-conventional husky
Copy the code

Husky is the ability to prevent git commits, git pushes, or other commands that do not meet requirements. The configuration is as follows:

{
    "husky": {
      "hooks": {
        "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"}}},Copy the code

Each commit is checked to see if the specified COMMIT MSG mode is met.

standard version

Standard Version is an NPM package that automatically generates versions and Changelog.md.

The installation

Install dependencies:

npm i --save-dev standard-version
Copy the code

Add the run script to package.json:

{
  "scripts": {
    "release": "standard-version"}}Copy the code

NPM run Release automatically generates Changelog.md and generates a COMMIT record and tag a new publication.

First release

Just run

NPM run release -- --first-release // or standard-version --first-releaseCopy the code

This generates a release tag, but does not change the version in package.json.

Release a pre-release

Use –prerelease to generate pre-releases: assume the current version is 1.0.0 and that the code to be committed is patched changes. Run:

npm run release -- --prerelease
Copy the code

Version 1.0.1-0 will be generated. To specify the pre-release version name, run –rerelease

. Such as:

npm run release -- --prerelease alpha
Copy the code

This tag will be 1.0.1-alpha.0

Publish the specified type

Use –release-as with the major or minor or patch parameter to cancel automatic version number generation. Assume the current version is 1.0.0. Run

//  npm run script
npm run release -- --release-as minor
//  Or
npm run release -- --release-as 1.1.0
Copy the code

Version 1.1.0 will be generated instead of the automatically generated version 1.0.1