Skip to content

A custom adapter to overwrite the default commitizen config with less boilerplate and options that make more sense. Using this makes it look like you know what you're doing.

Notifications You must be signed in to change notification settings

remcostoeten/custom-commitizen-adapter

Repository files navigation

Cleaner Commitizen Adapter

A custom Commitizen adapter/config for creating standardized commit messages with fewer terminal prompts and boilerplate. ✨

This stuff makes it look like you know what you're doing, dawg. 👀

t-rec

commit a401633a9362c3940c447daeaebaf264582da0f7
Author: Remco Stoeten <[email protected]>
Date:   Sat Jun 8 06:54:43 2024 +0200
chore: This video is such a chore man....

Installation

Since it's an adapter for Commitizen, you need to have Commitizen installed globally:

# Install Commitizen globally

npm install -g commitizen

# Install this package globally

npm install -g cleaner-commitizen-adapter

Commitizen does not support custom configuration via their own config file. To use this adapter you need to create a .czrc file in your home directory and set the path to the adapter. Edit/create the file with vim ~/.czrc and add the following line: { "path": "cleaner-commitizen-adapter" }. This will tell Commitizen to use the custom adapter.

Alternatively, you can run the following command to create the file with the correct content in one go:

echo '{ "path": "cleaner-commitizen-adapter" }' > ~/.czrc

Usage

To use this adapter with Commitizen, run:

cz

Answer the prompts to generate a standardized commit message.

Prompts

  1. Type of Change: Select the type of change you are committing. Options include:

    • feat: A new feature
    • fix: A bug fix
    • docs: Documentation only changes
    • style: Changes that do not affect the meaning of the code
    • refactor: A code change that neither fixes a bug nor adds a feature
    • test: Adding missing tests or correcting existing tests
    • chore: Changes to the build process or auxiliary tools
  2. Commit Message: Write a short, descriptive commit message.

Efficient Usage with zsh Alias

If you find the cz command annoying or having to git add, or push prior to running cz, you can create an alias in your .zshrc file to run the CLI tool with a single command.

  1. Open .zshrc Or .bashrc if you're using bash:

    vim ~/.zshrc
  2. Add alias:

    alias commit='cz'

Now, you can use the alias commit to quickly run the CLI tool. This allows you to type commit which could be more intuitive than cz.

Another one which I personally use, but must be used with caution due to the adding everything and pushing instantly is:

alias push='git add . && cz && git push'

A safe way to use this, but which is a little bit more time-consuming is to use the following alias:

alias push='git add . && cz && echo "You are about to push $(git diff --cached --numstat | wc -l) files." && echo "Are you sure you want to push these changes? (y/n/c) [Yes/No - commit only/No - abort all]" && read ans && if [[$ans = "y"]]; then git push; elif [[$ans = "n"]]; then echo "Changes committed, but not pushed."; else echo "Operation aborted."; git reset HEAD~; fi'

This will ask you after the commit if you want to continue with X files or not, giving you the option to push, quit, or only commit.

xxx love y'all,

Remco Stoeten

About

A custom adapter to overwrite the default commitizen config with less boilerplate and options that make more sense. Using this makes it look like you know what you're doing.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published