conventional-changelog / conventional-changelog/commitlint

Add option to reopen commit message editor on failed validation

Open
#2,152 4 comments 4 reactions 0 assignees View on GitHub
feature
Dominant language
TypeScript
Stars
18.7k
Forks
970
Avg merge
7h 33m
Merged PRs (30d)
49

Description

## Expected Behavior

1. You run `git commit` command in the command line.
2. Your editor (set by `EDITOR`) opens to allow you to enter the commit message.
3. You enter the message, save changes and quit the editor.
4. `commitlint` validates the message.
5. Depending on the validation:
- If the message validated successfully, the commit was made and you're back in the command line
- If the message didn't pass the validation, `commitlint` asks you if you want to retry editing the message:
* If you say yes, the editor is re-opened with the original message, allowing you to edit it and try again.
* If you say no, you're back in the command line with the editor state lost.

The proposed behavior in point 5 could be enabled/disabled using a configuration option.

## Current Behavior

Steps 1-4 are the same as in _Expected behavior_; only step 5 is different:

1. You run `git commit` command in the command line.
2. Your editor (set by `EDITOR`) opens to allow you to enter the commit message.
3. You enter the message, save changes and quit the editor.
4. `commitlint` validates the message.
5. You are back in the command line no matter if the validation passed:
- If the message validated successfully, the commit was made
- If the message didn't pass the validation, the commit wasn't made and the editor state was lost (though the message was printed). You need to manually copy the message, re-run `git commit` and paste it in the commit message editor again (to be able to make that commit and to not need to write the message from the scratch again).

## Affected packages

I don't know.

## Possible Solution

I don't know.

## Context

It's a bit irritating to need to re-run `git commit` copying the message, every time you make some error and the message won't pass the validation.

I know I could pass the message with a `-m` flag, which would make this problem less frustrating, but I find using the editor much more convenient, especially that on many occasions I write more than one paragraph in my commit messages.

## Your Environment

| Executable | Version |
| ---------------------: | :------ |
| `commitlint --version` | 9.1.2 |
| `git --version` | 2.28.0 |
| `node --version` | 14.12.0 |

Contributor guide

Open the contributing guide

Research direction

No source files or tests are named. Start by reproducing the command-line git commit flow with a deliberately invalid message, then trace the commitlint validation and configuration paths. Done means a configuration option controls whether the editor reopens with the original message after validation fails.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, typescript
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.