diff --git a/internal/batches/service/service.go b/internal/batches/service/service.go index 04ad873016..91babe2eef 100644 --- a/internal/batches/service/service.go +++ b/internal/batches/service/service.go @@ -648,7 +648,7 @@ func (svc *Service) FindDirectoriesInRepos(ctx context.Context, fileName string, a.WriteString("query DirectoriesContainingFile {\n") for _, repo := range batch { - query := fmt.Sprintf(`file:(^|/)%s$ repo:^%s$ type:path count:99999`, regexp.QuoteMeta(fileName), regexp.QuoteMeta(repo.Name)) + query := fmt.Sprintf(`file:(^|/)%s$ repo:^%s$@%s type:path count:99999`, regexp.QuoteMeta(fileName), repo.BaseRef(), regexp.QuoteMeta(repo.Name)) a.WriteString(fmt.Sprintf(searchQueryTmpl, queryIDByRepo[repo], query)) } diff --git a/internal/batches/service/service_test.go b/internal/batches/service/service_test.go index 8c6d08d3d6..5539a09815 100644 --- a/internal/batches/service/service_test.go +++ b/internal/batches/service/service_test.go @@ -327,8 +327,28 @@ func TestService_FindDirectoriesInRepos(t *testing.T) { fileName := "package.json" repos := []*graphql.Repository{ - {ID: "repo-id-0", Name: "github.com/sourcegraph/automation-testing", Branch: graphql.Branch{Name: "main"}}, - {ID: "repo-id-1", Name: "github.com/sourcegraph/sourcegraph", Branch: graphql.Branch{Name: "dev"}}, + { + ID: "repo-id-0", + Name: "github.com/sourcegraph/automation-testing", + Branch: graphql.Branch{Name: "dev"}, + DefaultBranch: &graphql.Branch{ + Name: "main", + Target: graphql.Target{ + OID: "d34db33f", + }, + }, + }, + { + ID: "repo-id-1", + Name: "github.com/sourcegraph/sourcegraph", + Branch: graphql.Branch{Name: "dev"}, + DefaultBranch: &graphql.Branch{ + Name: "main", + Target: graphql.Target{ + OID: "d34db33f", + }, + }, + }, } svc := &Service{client: client}