getcursor / cursor

The AI Code Editor
https://cursor.com
25.67k stars 1.59k forks source link

Auto-generate Git Commit Messages Using AI Analysis of Code Differences #786

Open kehao95 opened 1 year ago

kehao95 commented 1 year ago

Is your feature request related to a problem? Please describe. I often find myself struggling to accurately and concisely describe my code changes when making commits. This sometimes leads to commit messages that lack clarity or do not entirely capture the essence of the changes.

Describe the solution you'd like I'd like the AI code editor to incorporate a feature that automatically drafts a git commit message by analyzing the code changes from a given git diff. This would not only save time but also ensure that commit messages are clear, concise, and adequately descriptive.

Example: Given a git diff input, the AI should provide a draft for the commit message, taking into consideration the changes made and the context in which they were done.

Additional context Here's a proof of concept for how this feature could be used: Prompts:

given the following git diff, help me draft a git commit message.
... [git diff content] ...
I'm trying to solve istio not perseve source ip.

Result:

Update istio-ingressgateway to preserve source IP

- Modified the `istio-ingressgateway` Service in the development environment.
- Set `externalTrafficPolicy` to `Local` to ensure the original source IP is preserved, addressing issues with Istio not retaining the source IP.
- Referenced Google Cloud documentation on network tiers for clarity.

This will help developers in capturing their changes more accurately and save time that's often spent pondering the right words for a commit message.


truell20 commented 1 year ago

Do you use git over the command line? Or using the VSCode source control tab? Or some other UI?

kehao95 commented 1 year ago

I use both git CLI and VS Code Source Control Tab. But I'd love to see this feature as a button in the VSCode Source control tab.

stalinkay commented 1 year ago

@truell20 A CLI option will be much appreciated, e.g. cursor commit --dry-run or cursor generate-commit.

kamushadenes commented 1 year ago

Integrating with (or taking inspiration from) https://github.com/di-sukharev/opencommit would be great.

Elijas commented 1 year ago

I'd like to suggest the idea of using conventional commits. It's a practice that enhances the workflow by providing a more structured and easy-to-follow commit history.

Additionally, as we discuss this feature, I think it's important to remember that our commit messages should ideally explain not just what changes we've made, but also why we've made them. For example, a commit message like "change env var name" might not provide as much context as "fix crash issue". The latter gives us a clearer understanding of the purpose behind the change.

stalinkay commented 1 year ago

I second conventional commits. However, there are devs like myself who use Gitmoji and others who use conventional commits with Gitmoji.

adamlansky commented 1 year ago

I second this, would be amazing to have this!

jjfantini commented 1 year ago

we need it with gitmoji though!!