carloscuesta / gitmoji-cli

A gitmoji interactive cli tool for using emojis on commits. šŸ’»
https://www.npmjs.com/package/gitmoji-cli
MIT License
4.59k stars 206 forks source link

Allow custom commit title format #1002

Closed AmrAbdulrahman closed 1 year ago

AmrAbdulrahman commented 1 year ago

Description of the problem

Currently, the commit title is hardcoded as following:

`${answers.gitmoji} ${scope}${answers.title}`

This is not flexible and doesn't allow custom formats to meet different team conventions.

Solution

Allow new config field commitTitleFormat that accepts a string with placeholders to be filled out by the cli.

Example usage:

.gitmojirc.json

{
  "autoAdd": false,
  "emojiFormat": "emoji" ,
  "scopePrompt": false,
  "gitmojisUrl": "https://gitmoji.dev/api/gitmojis",
  "commitTitleFormat": "{{ticketid}} ({{scope}}): {{gitmoji}} {{title}}",
  "customFields": {    
    "ticketid": {
      "type": "string", // to be passed straight to inquirer
      "message": "Please enter Ticket ID", // to be passed straight to inquirer
      "default": "", // to be passed straight to inquirer
      "choices": ["A", "B"] // to be passed straight to inquirer
    }
  }
}

Alternatives

No response

Additional context

No response

Validations

AmrAbdulrahman commented 1 year ago

I am willing to create a MR for that if we agree on the approach @carloscuesta

carloscuesta commented 1 year ago

Hey! @AmrAbdulrahman thanks for opening an issue, this is actually very similar to what we discussed in #989 but scoped to the commit title instead of the message

I think we should definitely allow people to customise the way the "templates" are applied, without having to consider every possible use-case in the cli as it can be quite tricky to fit all the needs

I have to say though that the change you're suggesting is a bit against of the "convention" since the idea is to start the commit message prefixed with an emoji. As soon as you add a ticket reference it gets a bit lost

AmrAbdulrahman commented 1 year ago

For anyone having the same problem. I decided to better use commitlint along with gitmoji-commit-workflow for gitmoji integration.

It's much more flexible with custom formats and plugins, validations, and rules.

carloscuesta commented 1 year ago

Sure!!

Thanks for opening the issue šŸ™ŒšŸ»