-
Notifications
You must be signed in to change notification settings - Fork 0
Error when running ai-diff-commit: "ambiguous argument 'HEAD'" #26
Description
When attempting to run ai-diff-commit, an error occurs related to the HEAD argument in Git. The following error is displayed:
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
An error occurred: Error: Command failed: git rev-parse --abbrev-ref HEAD
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.The error seems to arise from a failure in the command git rev-parse --abbrev-ref HEAD, which is used to identify the current Git branch. This may happen if the repository is in a detached HEAD state or if there are no commits in the repository.
Steps to Reproduce:
- Run ai-diff-commit in a directory with a Git repository in a detached HEAD state or without any commits.
Expected Behavior: The tool should handle this scenario gracefully, possibly with a message indicating that a valid branch could not be detected.
Environment Details:
- OS: Windows
- Node Version: 20.18.0
- ai-diff-commit version: 0.0.3
Additional Context: The error traceback points to the getCurrentBranchName function in git.js. A potential fix could include handling scenarios where HEAD is ambiguous or ensuring the repository has a valid branch checked out.