Skip to content

Commit

Permalink
Merge pull request #42 from rockstaedt/33-update-readme-with-usage-ex…
Browse files Browse the repository at this point in the history
…ample

Update README with usage example
  • Loading branch information
rockstaedt authored Jan 18, 2024
2 parents b41ea1d + e6eae61 commit bfa7b11
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 12 deletions.
66 changes: 54 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# Commit Message Checker
# Commit Message Check

[![build](https://github.com/rockstaedt/commit-message-check/actions/workflows/CI.yml/badge.svg)](https://github.com/rockstaedt/commit-message-check/actions/workflows/CI.yml)
[![codecov](https://codecov.io/gh/rockstaedt/commit-message-check/branch/main/graph/badge.svg?token=VW245SMVP5)](https://codecov.io/gh/rockstaedt/commit-message-check)
[![Latest tag](https://img.shields.io/github/v/tag/rockstaedt/commit-message-check)](https://github.com/rockstaedt/commit-message-check/releases)

**Attention: Still under development!**

This is a commit message git hook to ensure that commit messages are not too
long.
Commit-message-check is a CLI tool that you can use in your terminal to ensure that your commit messages aren't too
long. It is easily setup and can be used for any git project.

## Installation

Expand All @@ -21,14 +19,58 @@ further [reference](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks).
curl -o install.sh -L https://raw.githubusercontent.com/rockstaedt/commit-message-check/main/install.sh && chmod +x ./install.sh && ./install.sh
```

## Usage (Deprecated)
## Usage

Everything is setup during the installation process. No further configuration is needed.

The tool is executed every time a commit is made. A commit message with more than 50 and less than 72 characters in the
subject line produces a warning. The exceeding characters are highlighted. See the following example:

![warning.png](docs%2Fwarning.png)

If the commit message is longer than 72 characters, the user will be asked if the commit should be aborted.

![abort.png](docs%2Fabort.png)

## Warning

The tool is not suitable for making commits from within an IDE. The commit will fail, showing an error message
indicating that the TTY device is not configured. I spent a lot of time researching if there is a possibility to cover
both use cases. Apparently, there is no way to distinguish between a commit made from within a terminal or an IDE.
If you have any ideas, please let me know! :)

As for now, I recommend to use the tool only for commits made from within a terminal. If you want to make a commit
from within an IDE, you can temporarily disable the hook by executing the following command:

```shell
./commit-message-check uninstall
```

This removes the git hook, and you can make a commit from within your IDE. If you want to enable the hook again,
simply execute the following command:

```shell
./commit-message-check setup
```

## Updates

Every time a git commit is made, the corresponding hook is fired. For a commit
message that is too long (>50 characters), the commit process is
aborted and a warning is shown. See the following as an example.
You can easily update the tool by executing the following command:

```shell
$ git commit -m "Veryyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy long"
2022/12/18 12:34:43 [INFO] Validating commit message...
2022/12/18 12:34:43 [ERROR] Abort commit. Subject line too long. Please fix.
./commit-message-check update
```

This will check the repository for a new release and download the latest binary.

## Contributions

Contributions are welcome! Please feel free to open an issue or a pull request. Also, if you have any ideas for
improvements, please do not hesitate to contact me. If you like the tool, please give it a star. :)

## Background

The idea to make this tool initiated in a pairing session with [mschirmer](https://github.com/mschirmer1301). Using
Code With Me from Jetbrains, we found ourselves using git a lot from within the terminal because
the commit tool window is only visible for the host. We wanted to have a simple way to ensure that our commit messages
are not too long as we were used to by the highlighting from within the IDE. This is how commit-message-check was born.
Binary file added docs/abort.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/warning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit bfa7b11

Please sign in to comment.