diff --git a/pkg/git_repo/local.go b/pkg/git_repo/local.go index dffd7b22ee..d8d9833e07 100644 --- a/pkg/git_repo/local.go +++ b/pkg/git_repo/local.go @@ -76,7 +76,7 @@ func OpenLocalRepo(ctx context.Context, name, workTreeDir string, opts OpenLocal return nil, fmt.Errorf("unable to get git status: %s", err) } - if len(gitStatusResult.PathList()) != 0 { + if len(gitStatusResult.PathListWithSubmodules()) != 0 { devHeadCommit, err := true_git.SyncSourceWorktreeWithServiceBranch( context.Background(), l.GitDir, diff --git a/pkg/true_git/status/result.go b/pkg/true_git/status/result.go index cd4af0528a..75f152299e 100644 --- a/pkg/true_git/status/result.go +++ b/pkg/true_git/status/result.go @@ -12,10 +12,21 @@ func (r *Result) IndexWithWorktree() Scope { return ComplexScope{scopes: []Scope{r.Index, r.Worktree}} } -// PathList returns a list of changed files -func (r *Result) PathList() (result []string) { +// PathListWithSubmodules returns a list of changed files +func (r *Result) PathListWithSubmodules() (result []string) { keys := map[string]bool{} - for _, path := range append(r.IndexWithWorktree().PathList(), r.UntrackedPathList...) { + + var allPaths []string + { + allPaths = append(allPaths, r.IndexWithWorktree().PathList()...) + for _, s := range r.IndexWithWorktree().Submodules() { + allPaths = append(allPaths, s.Path) + } + + allPaths = append(allPaths, r.UntrackedPathList...) + } + + for _, path := range allPaths { _, exist := keys[path] if !exist { result = append(result, path)