Skip to main content

Dead-simple tool for enforcing clean commit messages.

Project description

mkcommit

mkcommit is an extremely simple tool made for commit message generation.

Run mkcommit instead of git commit and you will be asked questions that keep your commits tidy even when it's 3 AM.

mkcommit gif

Why?

Why would anybody need this? Aren't editors enough?

When working in teams it's hard to enforce proper Git commit message style from everyone. This CLI tool asks you questions to build a commit message that you can configure for yourself and your team with a very simple Python script.

commitlint exists. Why mkcommit?

commitlint is a great tool. But it has considerable learning curve if you want to leverage its full potential. This tool strives to be the exact opposite: provide bare minimum with almost no overhead for your teammates. All they will need to learn is this one command: mkcommit.

mkcommit is:

  • Easy to install - all you need is Python (at least version 3.6).
  • Easy to configure - all you need is basic Python skills or advanced copy-pasting skills.
  • Easy to use - all you need is one command to trigger the commit prompt.
  • Scalable - it can be as complex as you want it, with full Git Hook integration and complex validation rules or just with a plain default Conventional Commit generation out-of-the-box.
  • Pythonic - might suit you better if you're familiar with Python and don't want to venture into the world of JavaScript.

Installation

If you have Python set up, you're good to go. Run pip install mkcommit and you're done.

Configuration

  1. At the root of your repository create a Python file named .mkcommit.py.

  2. Compose the script:

    • A built-in conventional commit suite can be used:

      from mkcommit import CommitMessage, to_stdout
      from mkcommit.suites import conventional
      
      def commit():
          return CommitMessage(*conventional.default())
      
      if __name__ == "__main__":
          to_stdout(commit())
      

      If you're not familiar with Conventional Commits, here's a quick guide.

    • If you need to define your own keywords and commit message template, read Configuration in our Wiki.

      • If you want to learn how to use the hook mode, read Hooks in our Wiki.
    • When you have implemented the file in one repo and want to use the exact same file in another repo, you should use include e.g.

      from mkcommit import to_stdout, include
      
      commit, on_commit = include("https://raw.githubusercontent.com/kjczarne/mkcommit/master/test/res/example.semantic.mkcommit.py")
      
      if __name__ == "__main__":
          to_stdout(commit())
      
  3. Run mkcommit. Select the discovered configuration file for the list and follow the interactive prompt.

Usage

  • Run mkcommit to generate a Git commit message and commit changes (calls git commit -m underneath).
  • Run mkcommit -s to generate a Git commit message and print it to standard output.
  • Run mkcommit -c to generate a Git commmit message and copy it to your clipboard.
  • Use mkcommit -x "some commit message" to validate an existing commit message from the command line or as a Git Hook command (requires on_commit(msg) function to be implemented in the configuration file).

If you wish to point mkcommit to a specific configuration file, use mkcommit -f /path/to/.mkcommit.py. You can combine the -f flag with all the other available flags.

Of course you may use mkcommit with VSCode tasks.

Input validation

The most basic validation strategy we use is validation at the time of message generation.

For validation of commit messages that aren't originally generated with mkcommit you can use Hooks.

Built-in suites

A list of suites that are supported out-of-the-box can be found in our Wiki.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

mkcommit-1.3.2-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file mkcommit-1.3.2-py3-none-any.whl.

File metadata

  • Download URL: mkcommit-1.3.2-py3-none-any.whl
  • Upload date:
  • Size: 22.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.1

File hashes

Hashes for mkcommit-1.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 03142bf1302f19817a75e3d267b2b193bff07ff33733c7995536f0fd4c5175eb
MD5 60733672980cf62943eff3cfa3bbb9fe
BLAKE2b-256 79c94655be189a46cd847ff9416809263d0864baa3f2a8cff0b741997170dd47

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page