Browse Source

Docs: Update usage instructions in README

This commit updates the README.md file to clarify the usage
instructions for the ai-commit.sh script. It now includes
instructions on how to amend the previous commit using the `-a`
or `--amend` flags. This enhancement provides users with clear
guidance on amending commits, improving the tool's usability.
Additionally, it documents the forwarding of arguments to the
python script.
seno 10 tháng trước cách đây
mục cha
commit
28137811a9
1 tập tin đã thay đổi với 17 bổ sung8 xóa
  1. 17 8
      README.md

+ 17 - 8
README.md

@@ -36,12 +36,19 @@ This tool automatically generates Git commit messages based on your staged chang
 ## Usage
 
 1.  **Stage your changes:** Use `git add` to stage the files you want to include in the commit.
-2.  **Run the script:** Execute the `ai-commit.sh` script from the root of your Git repository:
-    ```bash
-    ./ai-commit.sh
-    ```
+2.  **Run the script:**
+    *   **For a new commit:** Execute the `ai-commit.sh` script from the root of your Git repository:
+        ```bash
+        ./ai-commit.sh
+        ```
+    *   **To amend the previous commit:** Use the `-a` or `--amend` flag:
+        ```bash
+        ./ai-commit.sh -a
+        # or
+        ./ai-commit.sh --amend
+        ```
 3.  **Review and Confirm:** The script will:
-    - Fetch the staged diff.
+    - Fetch the staged diff (for a new commit) or the diff representing the changes to be amended (for an amend).
     - Generate a commit message using the Gemini API.
     - Print the generated message.
     - Ask for your confirmation (`y/n`).
@@ -53,12 +60,14 @@ This tool automatically generates Git commit messages based on your staged chang
 2.  It mounts the current directory (`pwd`) as `/repo` inside the container, allowing the script to access your Git repository.
 3.  It mounts your `.gitconfig` and `.git-credentials` (read-only) for Git operations within the container.
 4.  It passes the `GEMINI_API_KEY` environment variable into the container.
-5.  The `git_commit_ai.py` script:
+5.  It forwards any arguments passed to `ai-commit.sh` (like `-a` or `--amend`) to the Python script inside the container.
+6.  The `git_commit_ai.py` script:
+    - Parses command-line arguments (e.g., `--amend`).
     - Retrieves the staged diff using `git diff --staged`.
     - Sends the diff to the Gemini API with a prompt asking for a commit message.
     - Receives the generated message.
-    - Prompts the user for confirmation.
-    - If confirmed, runs `git commit -m "..."` with the generated message.
+    - Prompts the user for confirmation (mentioning if it's an amend).
+    - If confirmed, runs `git commit -m "..."` or `git commit --amend -m "..."` with the generated message.
 
 ## Files