File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,29 @@ local log = require("commit-ai.log")
22local M = {}
33
44function M .get_git_diff ()
5+ local status_lines = vim .fn .systemlist (' git status --porcelain' )
6+ local untracked_files = vim .tbl_filter (function (line )
7+ return line :match (" ^%?%?" )
8+ end , status_lines )
9+
10+ if # untracked_files > 0 then
11+ for _ , line in ipairs (untracked_files ) do
12+ local file = line :sub (4 )
13+ log .info (" ‼️ Untracked file: " .. file )
14+ end
15+ local answer = vim .fn .input (" Do you want to add them to the staging area? (y/n) " )
16+ if answer :lower () == " y" then
17+ for _ , line in ipairs (untracked_files ) do
18+ local file = line :sub (4 )
19+ vim .fn .system (" git add " .. file )
20+ log .info (" 📝 Added " .. file .. " to the staging area" )
21+ end
22+ else
23+ log .error (" Aborting" )
24+ return nil
25+ end
26+ return nil
27+ end
528 local staged_diff = vim .fn .system (' git diff --cached --no-color' )
629 if staged_diff == " " then
730 staged_diff = vim .fn .system (' git diff --no-color' )
You can’t perform that action at this time.
0 commit comments