Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom commit title format #1002

Closed
3 tasks done
AmrAbdulrahman opened this issue Feb 3, 2023 · 4 comments
Closed
3 tasks done

Allow custom commit title format #1002

AmrAbdulrahman opened this issue Feb 3, 2023 · 4 comments
Labels

Comments

@AmrAbdulrahman
Copy link

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
Copy link
Author

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

@carloscuesta
Copy link
Owner

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
Copy link
Author

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
Copy link
Owner

Sure!!

Thanks for opening the issue 🙌🏻

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants