Nutlope / aicommits

A CLI that writes your git commit messages for you with AI
https://www.npmjs.com/package/aicommits
MIT License
7.77k stars 366 forks source link

Extract issue name from branch and append to commit message #254

Closed aozmekik closed 11 months ago

aozmekik commented 11 months ago

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 aicommits 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 aicommits 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 aicommits 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

Alternatives

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

git commit --amend

And I am pushing it.

negoziator commented 11 months ago

@aozmekik I have forked the repo, since this is no longer maintained.

If you make the issue here: https://github.com/negoziator/ai-commit/issues

Then i will look at it right away. I actually already do this in my zsh when commiting without ai-commit, so it get your point completly đŸ˜„

aozmekik commented 11 months ago

@negoziator I did it.