Skip to content

Conversation

@malpou
Copy link
Contributor

@malpou malpou commented Sep 7, 2023

This PR modifies opencommit to better support the Gitmoji convention, ensuring compatibility with projects that currently use Gitmoji.

Changes

  • Added a utility method in removeConventionalCommitWord.ts to adjust the commit format according to the Gitmoji guidelines.

  • Updated prompts.ts to dynamically generate prompts based on whether the OCO_EMOJI configuration option is enabled. When enabled, prompts will guide users to follow the Gitmoji format.

Notes
I'm unsure if this is the best approach to implement Gitmoji support. Specifically:

  • The changes may add too many tokens to each request.
  • There's a potential for simplifying the list by removing less commonly used emojis.

Issue #239

Feedback is much appreciated!

Best regards
@malpou

…t GitMoji convention and descriptions of changes

📝 docs(prompts.ts): update prompt message to include information about GitMoji convention and descriptions of changes
…ove conventional commit word from commit prompts

🐛 (prompts.ts): remove conventional commit word from `commitFix` and `commitFeat` prompts to improve clarity
📝 (removeConventionalCommitWord.ts): add `removeConventionalCommitWord` function to remove conventional commit word from commit message
@shkreios
Copy link

shkreios commented Sep 7, 2023

Hi @malpou, I've tested your PR locally, and it does enhance the specificity of GPT's emoji output, moving away from the constant use of 🔧. However, it seems to have lost the prefixing of messages with tags like fix, chore, etc.

Additionally, the increased token count due to the inclusion of various emojis and explanations may not be universally beneficial. Perhaps a flag to toggle this feature on a per-commit basis could be a worthwhile addition. What do you think?

@malpou
Copy link
Contributor Author

malpou commented Sep 7, 2023

Thanks for looking at it @shkreios

The loss of fix, chore, etc, is done on purpose.
This is due to the changes on src/prompts.ts:143-144.

As my understanding the fix & chore are keywords in Conventional Commits and not present in the GitMoji standard.

Quote from issue:

In the context of Gitmoji, the emoji already provides enough context as to what the commit is about. Titles should also use sentence case.

If it should be a flag I'm not sure:

I think these changes are moving us closer to having two options of commit messages one being Conventional Commits and the other being GitMoji.

Then the OCO_EMOJI configuration will be the opt-in toggle to use GitMoji instead of Conventional Commits.

If we go with this approach we should maybe work on the prompts making our non-emoji messages be more forced towards the conventional commits spec: https://www.conventionalcommits.org/en/v1.0.0/#specification

Let me hear your thoughts 😄

cc: @stalinkay & @di-sukharev

@shkreios
Copy link

shkreios commented Sep 7, 2023

Hey @malpou,

As my understanding the fix & chore are keywords in Conventional Commits and not present in the GitMoji standard.

Understood, and it's logical to align with the Conventional Commits standard. While I personally preferred the prior commit style, the standard takes precedence.

If it should be a flag I'm not sure:

My primary concern is the frequent need to switch between gpt-4 and gpt-3.5-turbo-16k due to token limits. This impacts whether I can effectively utilize the CLI for certain commits. A substantial increase in the base prompt length often proves counterproductive in my specific cases.

@malpou
Copy link
Contributor Author

malpou commented Sep 7, 2023

I just had an idea, What if we select a few standard emojis from GitMoji and always add these to the emoji prompts.

Then I'll add a flag you can include if you want ALL of the GitMoji emojis.

Toughts @shkreios ?

@malpou
Copy link
Contributor Author

malpou commented Sep 7, 2023

The flag could be called --fgm for Full GitMoji

@malpou
Copy link
Contributor Author

malpou commented Sep 7, 2023

This is the list of emojis i would prioritize:

  • 🐛 Fix a bug
  • ✨ Introduce new features
  • 📝 Add or update documentation
  • 🚀 Deploy stuff
  • ✅ Add, update, or pass tests
  • ♻️ Refactor code
  • ⬆️ Upgrade dependencies
  • 🔧 Add or update configuration files
  • 🌐 Internationalization and localization
  • 💡 Add or update comments in source code

… '--fgm' flag in the CLI command

🔧 (commit.ts): pass the value of the 'fgm' flag to the 'commit' function to enable or disable full GitMoji specification
♻️ (commit.ts): refactor the 'commit' function to accept the 'fullGitMojiSpec' parameter and pass it to the 'commit' function recursively
♻️ (generateCommitMessageFromGitDiff.ts): refactor the 'generateCommitMessageByDiff' function to accept the 'fullGitMojiSpec' parameter and pass it to the 'generateCommitMessageChatCompletionPrompt' function
♻️ (generateCommitMessageFromGitDiff.ts): refactor the 'generateCommitMessageChatCompletionPrompt' function to accept the 'fullGitMojiSpec' parameter and pass it to the 'getMainCommitPrompt' function
♻️ (generateCommitMessageFromGitDiff.ts): refactor the 'getCommitMsgsPromisesFromFileDiffs' function to accept the 'fullGitMojiSpec' parameter and pass it to the 'getMessagesPromisesByChangesInFile' function
♻️ (generateCommitMessageFromGitDiff.ts): refactor the 'getMessagesPromisesByChangesInFile' function to accept the 'fullGitMojiSpec' parameter and pass it to the 'generateCommitMessageChatCompletionPrompt' function
♻️ (prompts.ts): refactor the 'getMainCommitPrompt' function to accept the 'fullGitMojiSpec' parameter and pass it to the 'INIT_MAIN_PROMPT' function
…mmand to enable the use of the full GitMoji specification
@malpou
Copy link
Contributor Author

malpou commented Sep 8, 2023

@shkreios there is new stuff to look at whenever you have time 😄

…cation

📝 (README.md): add link to the GitMoji specification for reference
… Specification` flag

🔧 (api.ts): update the default value of the `apiKey` variable to a placeholder value for testing purposes
… GitMoji Specification` flag"

This reverts commit 230a4aa.
…n about the fullGitMojiSpec flag and provide instructions on how to choose the right emoji for the commit message
@malpou
Copy link
Contributor Author

malpou commented Sep 12, 2023

@di-sukharev
Any blockers on this?

@shkreios
Copy link

shkreios commented Sep 20, 2023

@shkreios there is new stuff to look at whenever you have time 😄

Sorry i was currently busy i try to have a look this week

@github-actions
Copy link

Stale pull request message

@di-sukharev
Copy link
Owner

will test and merge

@di-sukharev
Copy link
Owner

@malpou i've resolved the readme conflict, have you tested this PR by building npm run build && npm run start -- <flags>? I will also try to get to it while you are busy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants