Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,25 +361,25 @@ Automates the commit process using AI. This command has three main modes:
When run without flags (or with `-n`), it automates the creation of a new commit:
1. Stages all current changes (`git add .`).
2. Generates a commit message based on the staged diff.
3. Opens a commit message buffer for editing. The buffer lists all files included in the commit as comments at the bottom.
4. In Normal mode, move the cursor over the file list and press `<Space>` to toggle file inclusion (deselected files are marked with a `-` sign, and pressing `<Space>` again re-adds them).
5. Save and close the buffer to commit. All files marked with `-` are removed from the commit, and only the remaining files are committed. Close without saving to abort.
3. Opens a commit message buffer for editing. The buffer displays the diff stat with all files included in the commit as comments at the bottom.
4. In Normal mode, move the cursor over the diff stat file line and press `<Space>` to toggle file inclusion (deselected files are marked with `#-`, and pressing `<Space>` again re-adds them) to exclude the file.
5. Save and close the buffer to commit. All deselected files are removed from the commit, and only the remaining files are committed. Close without saving to abort.

**Regenerate Mode (`-r`):**

When run with the `-r` flag, it regenerates the commit message for the last commit (`HEAD`) and amends it:
1. It gets the diff from the `HEAD` commit.
2. It generates a new commit message based on that diff.
3. Opens the commit message buffer listing the files in `HEAD` (press `<Space>` in Normal mode to toggle/deselect files).
4. If confirmed and saved, it amends the `HEAD` commit with the new message and deselected files removed.
3. Opens the commit message buffer listing the diff stat for `HEAD` (file toggling is not available in regenerate mode).
4. If confirmed and saved, it amends the `HEAD` commit with the new message.

**Amend Code and Regenerate Mode (`-a`):**

When run with the `-a` flag, it amends the current working tree changes into the last commit (`HEAD`) and regenerates the commit message:
1. Stages current changes.
2. Amends the code into `HEAD` (`git commit --amend --no-edit`).
3. Generates a new commit message based on the new combined diff from `HEAD`.
4. Opens the commit message buffer listing files (press `<Space>` in Normal mode to toggle/deselect files).
4. Opens the commit message buffer listing the combined diff stat (press `<Space>` in Normal mode to toggle/deselect files with `#-`).
5. If confirmed and saved, it amends the `HEAD` commit with the new message and deselected files removed.

You can also provide optional `[instructions]` at the end of the command to guide the AI's message generation (e.g., "Mention issue #123" or "Keep it very brief").
Expand Down
10 changes: 6 additions & 4 deletions doc/vimini.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ COMMANDS *vimini-commands*

*:ViminiCommit* [-n] [-r] [-a] [instruction]
Generates a commit message and commits changes using Gemini.
Files included in the commit are listed as comments at the bottom of the
buffer. In Normal mode, press <Space> on a file to toggle its inclusion
(deselected files are marked with -). When saved and closed, deselected
files are removed and only remaining files are committed.
Files included in the commit are shown in the diff stat comments at the
bottom of the buffer. In Normal mode, press <Space> on a file to toggle its
inclusion (deselected files are marked with #-), or delete the file's line.
When saved and closed, deselected files are removed and only remaining
files are committed (file toggling is not available in regenerate mode with
-r).
-n: Omit co-author trailer.
-r: Regenerate commit message for HEAD and amend.
-a: Amend working tree changes into HEAD and regenerate commit message.
Expand Down
4 changes: 2 additions & 2 deletions plugin/vimini.vim
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,8 @@ command! -nargs=* ViminiCommit call ViminiCommit(<q-args>)
function! ViminiCommitToggleFile()
py3 << EOF
try:
from vimini.commit import toggle_file
toggle_file()
from vimini import main
main.toggle_file()
except Exception as e:
pass
EOF
Expand Down
4 changes: 4 additions & 0 deletions python3/vimini/agent/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ def execute_function(req_id, method, params, result_queue, conn):
"regenerate": params.get("regenerate")
if isinstance(params, dict)
else False,
"amend": params.get("amend") if isinstance(params, dict) else False,
"orig_head": params.get("orig_head")
if isinstance(params, dict)
else None,
"assistant": params.get("assistant")
if isinstance(params, dict)
else True,
Expand Down
9 changes: 8 additions & 1 deletion python3/vimini/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,14 @@ def apply_patch(diff_content, project_root=None, silent=False):
except FileNotFoundError:
# Fall back to git apply if patch command is not in PATH
try:
git_cmd = ["git", "-C", project_root, "apply", "--whitespace=nowarn", "-"]
git_cmd = [
"git",
"-C",
project_root,
"apply",
"--whitespace=nowarn",
"-",
]
result = subprocess.run(
git_cmd,
input=diff_content,
Expand Down
Loading
Loading