Skip to content
This repository was archived by the owner on Mar 9, 2026. It is now read-only.

Commit 429421f

Browse files
committed
Refactor CLI to use git diff with 10 lines of context #️⃣
1 parent 2878710 commit 429421f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

aicodebot/cli.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,17 @@ def commit(verbose, max_tokens, yes):
100100

101101
# Get the changes from git
102102
staged_files = exec_and_get_output(["git", "diff", "--name-only", "--cached"])
103+
base_git_diff = ["git", "diff", "-U10"] # Tell diff to provide 10 lines of context
103104
if not staged_files:
104105
# If no files are staged, stage all changed files
105106
exec_and_get_output(["git", "add", "-A"])
106107
# Get the diff for all changes since the last commit
107-
diff = exec_and_get_output(["git", "diff", "HEAD"])
108+
diff = exec_and_get_output(base_git_diff + ["HEAD"])
108109
# Get the list of files to be committed
109110
files = exec_and_get_output(["git", "diff", "--name-only", "--cached"])
110111
else:
111112
# If some files are staged, get the diff for those files
112-
diff = exec_and_get_output(["git", "diff", "--cached"])
113+
diff = exec_and_get_output(base_git_diff + ["--cached"])
113114
# The list of files to be committed is the same as the list of staged files
114115
files = staged_files
115116

0 commit comments

Comments
 (0)