Skip to content

Instantly share code, notes, and snippets.

@Narixius
Last active July 29, 2021 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Narixius/c1eea454de6219ccb0f43d804a368319 to your computer and use it in GitHub Desktop.
Save Narixius/c1eea454de6219ccb0f43d804a368319 to your computer and use it in GitHub Desktop.
Introduction to commitizen

Resource for https://www.youtube.com/watch?v=JlfCRlFHmd8

ref: https://github.com/DevInsideYou/learning-resources/blob/master/Conventional.md

ref: https://www.conventionalcommits.org/en/v1.0.0/

Linux

sudo npm install -g commitizen
sudo npm install -g cz-conventional-changelog

Feel free to use a target local to your project.

echo '{ "path": "cz-conventional-changelog" }' > ~/.czrc

Windows

npm install -g commitizen
npm install -g cz-conventional-changelog

cz-emoji (optional)

Note: this requires changes to commitlint.

sudo npm install -g cz-emoji

Replaces cz-conventional-changelog.

echo '{ "path": "cz-emoji" }' > ~/.czrc

Optionally use unicode instead of gitmoji by editing the ~/.czrc:

{
  "path": "cz-emoji",
  "config": {
    "cz-emoji": {
      "symbol": true
    }
  }
}

Vscode Extension

It can be used to push from vscode to git server

https://marketplace.visualstudio.com/items?itemName=KnisterPeter.vscode-commitizen

It will be used to generate changelog that contains a full information about new features, breaking changes, refactors, bug fixes and etc... . It's good for versioin releasing.

npm install -g conventional-changelog-cli
cd my-project
conventional-changelog -p angular -i CHANGELOG.md -s

Automatically lint your commit messages

cd /path/to/my/repo

echo 'echo "$(cat $1)" | commitlint' > .git/hooks/commit-msg
chmod +x .git/hooks/commit-msg
sudo npm install -g standard-version

Version bumps for Scala SBT projects

Contents of my-project/.versionrc.json:

{
  "bumpFiles": [
    {
      "filename": "version.sbt",
      "updater": "standard-version-updater.js"
    }
  ]
}

Contents of my-project/standard-version-updater.js:

module.exports.readVersion = contents =>
  contents.match(/"(?<version>.*)"/).groups.version

module.exports.writeVersion = (_, version) =>
  `ThisBuild / version := "${version}"\n`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment