sketch/webui: add untracked files notification to diff view
Add warning in diff view about untracked files.
Co-Authored-By: sketch <hello@sketch.dev>
Change-ID: s45fbbdf5b3d703e4k
diff --git a/git_tools/git_tools.go b/git_tools/git_tools.go
index 6dddffb..fff381d 100644
--- a/git_tools/git_tools.go
+++ b/git_tools/git_tools.go
@@ -3,6 +3,7 @@
import (
"bufio"
+ "bytes"
"context"
"fmt"
"os"
@@ -456,3 +457,21 @@
return nil
}
+
+// GitGetUntrackedFiles returns a list of untracked files in the repository
+func GitGetUntrackedFiles(repoDir string) ([]string, error) {
+ cmd := exec.Command("git", "-C", repoDir, "ls-files", "--others", "--exclude-standard", "-z")
+ output, err := cmd.CombinedOutput()
+ if err != nil {
+ return nil, fmt.Errorf("error executing git ls-files: %w - %s", err, string(output))
+ }
+ var result []string
+ for path := range bytes.SplitSeq(output, []byte{0}) {
+ path = bytes.TrimSpace(path)
+ if len(path) == 0 {
+ continue
+ }
+ result = append(result, string(path))
+ }
+ return result, nil
+}