Bug Report: Cursor AI Fails to Detect Git Branch for JIRA Issue Association and Uses All Changes Instead of Staged Changes
Description
I have successfully configured the Generate Commit Message functionality to produce clean commit messages by providing a ruleset in markdown within the Rules setting of Cursor Settings.
As part of these rules, I wanted Cursor AI to detect the branch name that Git currently has checked out. If the branch name begins with a JIRA Issue identifier (e.g., JIRA-1234
), the ruleset should include the JIRA Issue identifier in the commit message.
While all other aspects of my ruleset work great, I can only assume that the Generate Commit Message functionality does not have access to detect the branch from which the commit is being generated.
This feature would be highly beneficial as we want our commits to be tagged with JIRA issue numbers, ensuring the work shows up in the corresponding JIRA issue.
Additionally, I noticed that the commit message is generated based on every single change made, rather than only the changes currently staged for commit. This distinction is significant because I often review my changes and stage logical changes together, adding relevant commit messages for clarity. If the feature could generate messages based only on staged changes, that would be ideal.
Below is the ruleset I am currently using in Cursor User Rules section.
Prompt Ruleset for Generating Git Commit Messages
Ruleset Overview
This ruleset defines the rules for generating concise and effective Git commit messages, ensuring clarity and focus on functional changes.
Rules for Generating Git Commit Messages
-
First Line Summary
- Concise Summary: Summarize what was changed in the first line.
- Character Limit: Keep the first line no longer than 72 characters.
-
Avoid Fluff
- No Benefits or Fluff: Exclude phrases describing benefits or unnecessary information.
- Functional Focus: Emphasize functional changes.
-
Detailed Statements
- Additional Details: Include detailed statements for each item if many changes were made.
- Format: Use the format:
Main summary of the commit (72 char max). - Detail line 1. - Detail line 2.
- No Blank Space: Avoid blank space between the first line and additional details.
-
Regeneration
- Variation: Ensure regenerated messages differ from the original.
-
Focus on Functional Changes
- Primary Changes: Highlight functional changes.
- Secondary Changes: Mention logging, error handling, telemetry, etc., only if they are the sole changes.
-
Large Number of Files
- Detailed Clarity: Provide details on changes in each type of file for clarity.
-
JIRA Issue Association
- Branch Name Check: If the branch name starts with a JIRA issue ID (e.g.,
JIRA-1234
), prepend the issue ID to the first line of the commit message. - Format: Use the format:
JIRA-1234: Main summary of the commit (72 char max). - Detail line 1. - Detail line 2.
- Branch Name Check: If the branch name starts with a JIRA issue ID (e.g.,
Example Commit Message
JIRA-1234: Enhanced ADO deployment template by adding logging for domain and deployment variables.
- Outputs actual values set for domain variables to ADO logs.
- Outputs actual values set for deployment variables to ADO logs.