git-cm icon indicating copy to clipboard operation
git-cm copied to clipboard

Add a flag that allows for compact output

Open tbarusseau opened this issue 5 years ago • 7 comments

As of now, all commit messages seem to be spaced out:

    ci(CircleCI)!: Renamed main build job
    
    Renamed main build job from `build-base` to `base`
    
    BREAKING CHANGE: The `build-base` is now named `base`
    
    123

Allowing the user to generate a more compact message with -c/--compact would be neat:

    ci(CircleCI)!: Renamed main build job
    Renamed main build job from `build-base` to `base`
    BREAKING CHANGE: The `build-base` is now named `base`
    123

tbarusseau avatar Jul 17 '20 17:07 tbarusseau

This could be taken further by introducing some kind of template where a user can define their own template and formatting (commits.template):

{type}{if has_scope: ({scope})}{if is_breaking: !}: {short_msg}
{long_msg}
{if is_breaking: BREAKING CHANGES: {breaking_changes}}
{if are_affected: issues_affected}

Just an idea :)

mainrs avatar Jul 17 '20 17:07 mainrs

Are you alright with adding structopt for command-line arguments parsing?

tbarusseau avatar Jul 17 '20 19:07 tbarusseau

I've worked with both structopt and clap. Since structopt does rely on clap anyway and has been merged into the 3.0-alpha I'd rather use that version of clap.

mainrs avatar Jul 17 '20 19:07 mainrs

I am working on #12, so this could be solved with it. Not sure if I want to add a flag for it or just provide an alternative template inside the repo that people can use, as my main goal is to follow the conventional commits specification.

mainrs avatar Jul 19 '20 10:07 mainrs

While it makes sense for the spec to separate the title, body, and footer, on shorter commit messages it's a pity to have 2 newlines for 3 lines of content. I agree that it's important to follow a specification for the commits, but if only the commits were pretty to look at as well!

tbarusseau avatar Jul 20 '20 07:07 tbarusseau

So I have thinking about this for a while and I will probably include a compact version of the current template without the new lines. However, the help screen will have a note that it is not compliant with the specification.

mainrs avatar Jul 20 '20 22:07 mainrs

That sounds great!

tbarusseau avatar Jul 21 '20 09:07 tbarusseau