Add a read-only Files tab browsing a task's worktree

This commit is contained in:
Ian Gulliver
2026-10-15 07:31:53 -07:00
parent 4ca6f88861
commit de5b944a0c
16 changed files with 1460 additions and 123 deletions
+37
View File
@@ -0,0 +1,37 @@
package git
import (
"bytes"
"errors"
"fmt"
"os/exec"
"strings"
)
func Ignored(worktree string, paths []string) (map[string]bool, error) {
ignored := map[string]bool{}
if len(paths) == 0 {
return ignored, nil
}
cmd := exec.Command("git", "check-ignore", "--stdin", "-z")
cmd.Dir = worktree
cmd.Stdin = strings.NewReader(strings.Join(paths, "\x00") + "\x00")
stderr := &strings.Builder{}
cmd.Stderr = stderr
out, err := cmd.Output()
exit := &exec.ExitError{}
if errors.As(err, &exit) && exit.ExitCode() == 1 {
return ignored, nil
}
if err != nil {
return nil, fmt.Errorf("git check-ignore: %w: %s", err, strings.TrimSpace(stderr.String()))
}
for _, p := range bytes.Split(out, []byte{0}) {
if len(p) > 0 {
ignored[string(p)] = true
}
}
return ignored, nil
}