Skip to content

Commit

Permalink
fix(dev): submodule changes may not be taken into account
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-igrychev committed Oct 4, 2021
1 parent 4faa97d commit f3b2fab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/git_repo/local.go
Expand Up @@ -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,
Expand Down
17 changes: 14 additions & 3 deletions pkg/true_git/status/result.go
Expand Up @@ -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)
Expand Down

0 comments on commit f3b2fab

Please sign in to comment.