Skip to content

Instantly share code, notes, and snippets.

@woile
Last active July 24, 2020 13:11
Show Gist options
  • Save woile/92ef2c935b7bec9a17debafa1c7a4f80 to your computer and use it in GitHub Desktop.
Save woile/92ef2c935b7bec9a17debafa1c7a4f80 to your computer and use it in GitHub Desktop.
Dissecting commitizen

Commitizen

Tool to automate a semantic release

Commands

Provides a few commands:

    init                init commitizen configuration
    commit (c)          create new commit
    ls                  show available commitizens
    example             show commit example
    info                show information about the cz
    schema              show commit schema
    bump                bump semantic version based on the git log
    changelog (ch)      generate changelog (note that it will overwrite
                        existing file)
    check               validates that a commit message matches the commitizen
                        schema
    version             get the version of the installed commitizen or the
                        current project (default: installed commitizen)

Most used commands

cz commit

cz bump --changelog

Source code

.
├── CHANGELOG.md
├── commitizen
│   ├── bump.py
│   ├── changelog_parser.py
│   ├── changelog.py
│   ├── cli.py
│   ├── cmd.py
│   ├── commands
│   │   ├── bump.py
│   │   ├── changelog.py
│   │   ├── check.py
│   │   ├── commit.py
│   │   ├── example.py
│   │   ├── info.py
│   │   ├── __init__.py
│   │   ├── init.py
│   │   ├── list_cz.py
│   │   ├── __pycache__
│   │   ├── schema.py
│   │   └── version.py
│   ├── config
│   │   ├── base_config.py
│   │   ├── ini_config.py
│   │   ├── __init__.py
│   │   ├── __pycache__
│   │   └── toml_config.py
│   ├── cz
│   │   ├── base.py
│   │   ├── conventional_commits
│   │   │   ├── conventional_commits_info.txt
│   │   │   ├── conventional_commits.py
│   │   │   ├── __init__.py
│   │   │   └── __pycache__
│   │   ├── customize
│   │   │   ├── customize_info.txt
│   │   │   ├── customize.py
│   │   │   ├── __init__.py
│   │   │   └── __pycache__
│   │   ├── exceptions.py
│   │   ├── __init__.py
│   │   ├── jira
│   │   │   ├── __init__.py
│   │   │   ├── jira_info.txt
│   │   │   ├── jira.py
│   │   │   └── __pycache__
│   │   ├── __pycache__
│   │   └── utils.py
│   ├── defaults.py
│   ├── exceptions.py
│   ├── factory.py
│   ├── git.py
│   ├── __init__.py
│   ├── __main__.py
│   ├── out.py
│   ├── __pycache__
│   ├── templates
│   │   └── keep_a_changelog_template.j2
│   └── __version__.py
├── docs/
├── mkdocs.yml
├── pyproject.toml
├── scripts
│   ├── lint
│   ├── publish
│   └── test
└── tests/

Highlights

  • commitizen/cli.py describes the whole client interface in a declarative manner.
  • the folder src/commands contains the source for each command.
  • each command lives in its own filecz commit -> commitizen/commands/commit.py.
  • files are used mostly as namespaces commitizen/git.py contains the git related operations, commitizen/bump.py contains all about bumping a version.

Recommendations

  • try using TDD, this enforces a good interface design from the beginning.

If it's easy to test, it's easy to use.

  • write tests for each new fix.
  • documentation is very important to us, it's highly appreciated if you contribute with documentation.
  • optional: use conventional commits, if they are not used we'll squash the commit with the correct commit message

Workflow

  • start with documentation and bug fixes.
  • continue with breaking changes issues (tagged as 2.0).

Branch

breaking changes: next

normal changes: master

⬆️ Make PRs to those branches ⬆️

Resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment