Skip to content

Commit b1eb16e

Browse files
committed
feat: add monorepo git status check fallback for local packages without standalone .git
1 parent ce703bd commit b1eb16e

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

go/tui/tui.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2614,6 +2614,30 @@ func runGitStatus(dir string) (added, modified, deleted int, err error) {
26142614
return added, modified, deleted, nil
26152615
}
26162616

2617+
func runGitStatusForSubdir(rootDir, subdir string) (added, modified, deleted int, err error) {
2618+
cmd := exec.Command("git", "status", "--porcelain", subdir)
2619+
cmd.Dir = rootDir
2620+
out, err := cmd.Output()
2621+
if err != nil {
2622+
return 0, 0, 0, err
2623+
}
2624+
lines := strings.Split(string(out), "\n")
2625+
for _, line := range lines {
2626+
if len(line) < 3 {
2627+
continue
2628+
}
2629+
status := line[:2]
2630+
if strings.HasPrefix(status, "??") {
2631+
added++
2632+
} else if strings.Contains(status, "D") {
2633+
deleted++
2634+
} else if strings.Contains(status, "M") || strings.Contains(status, "A") || strings.Contains(status, "R") || strings.Contains(status, "C") {
2635+
modified++
2636+
}
2637+
}
2638+
return added, modified, deleted, nil
2639+
}
2640+
26172641
func runGitBehindCheck(dir string) (int, error) {
26182642
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
26192643
defer cancel()
@@ -2765,6 +2789,16 @@ func (m TuiModel) checkForUpdatesCmd() tea.Cmd {
27652789
if err == nil && behind > 0 {
27662790
res.update = &UpdateInfo{LocalGit: true, BehindCount: behind}
27672791
}
2792+
} else {
2793+
// Fallback: Check if the monorepo itself tracks changes for this directory
2794+
parentGitDir := filepath.Join(m.workspaceRoot, ".git")
2795+
if _, err := os.Stat(parentGitDir); err == nil {
2796+
relPath := filepath.Join(kindDir, short)
2797+
added, modified, deleted, err := runGitStatusForSubdir(m.workspaceRoot, relPath)
2798+
if err == nil && (added > 0 || modified > 0 || deleted > 0) {
2799+
res.changes = &GitChanges{Added: added, Modified: modified, Deleted: deleted}
2800+
}
2801+
}
27682802
}
27692803
}
27702804

0 commit comments

Comments
 (0)