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

Feature Request: Extract Issue Name from Branch and Append to Commit Message #16

Open
aozmekik opened this issue Oct 11, 2023 · 0 comments

Comments

@aozmekik
Copy link

Feature Request: Extract Issue Name from Branch and Append to Commit Message

Overview

For developers who follow a naming convention for their branches that includes an issue name or identifier, it would be beneficial for the ai-commit tool to automatically extract this issue name and append it to the generated commit message. This ensures that each commit is directly associated with the relevant issue, providing better traceability and context.

Current Behavior

Currently, when using the ai-commit tool, the generated commit message is in the format:

<commit_msg>

Desired Behavior

Given a branch name that follows the convention feature/abc-576, bugfix/abc-577, etc., the tool should extract the issue name (e.g., abc-576) and append it to the commit message. The resulting commit message should be:

abc-576 <commit_msg>

Use Case

Consider a developer working on a feature branch named feature/abc-576. They make some changes and stage them. When they use the ai-commit tool to generate a commit message, the tool should:

  1. Detect the current branch name.
  2. Extract the issue name from the branch name.
  3. Append the issue name to the generated commit message.

For example, if the AI-generated commit message is "Added new login functionality", the final commit message should be:

abc-576 Added new login functionality 

Implementation Suggestions

  1. Use Git commands to detect the current branch name.
  2. Use regular expressions or string manipulation to extract the issue name from the branch name.
  3. Append the issue name to the AI-generated commit message.

Benefits

  • Traceability: By associating commits with specific issues, developers and teams can easily trace changes back to their originating requirements or bug reports.

  • Context: When reviewing commit histories, having the issue name directly in the commit message provides immediate context about the purpose of the change.

  • Integration with Other Tools: Many project management and CI/CD tools can utilize the issue name in the commit message for better automation and linking of code changes to tasks.

Alternatives

I am editing the commit message in this way right now,

git commit --amend

And I am pushing it.

Repository owner deleted a comment Jan 3, 2024
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

No branches or pull requests

1 participant