Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit 79626da

Browse files
authored
Move fallback from . to "" in workspace path into workspace finder (#605)
1 parent 2275dcf commit 79626da

File tree

3 files changed

+21
-27
lines changed

3 files changed

+21
-27
lines changed

internal/batches/service/build_tasks.go

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,21 @@ func buildTasks(ctx context.Context, spec *batcheslib.BatchSpec, workspaces []Re
1414
tasks := make([]*executor.Task, 0, len(workspaces))
1515

1616
for _, ws := range workspaces {
17-
tasks = append(tasks, buildTask(spec, ws))
17+
task := &executor.Task{
18+
Repository: ws.Repo,
19+
Path: ws.Path,
20+
Steps: ws.Steps,
21+
OnlyFetchWorkspace: ws.OnlyFetchWorkspace,
22+
23+
TransformChanges: spec.TransformChanges,
24+
Template: spec.ChangesetTemplate,
25+
BatchChangeAttributes: &template.BatchChangeAttributes{
26+
Name: spec.Name,
27+
Description: spec.Description,
28+
},
29+
}
30+
tasks = append(tasks, task)
1831
}
1932

2033
return tasks
2134
}
22-
23-
func buildTask(spec *batcheslib.BatchSpec, workspace RepoWorkspace) *executor.Task {
24-
batchChange := template.BatchChangeAttributes{
25-
Name: spec.Name,
26-
Description: spec.Description,
27-
}
28-
29-
// "." means the path is root, but in the executor we use "" to signify root.
30-
path := workspace.Path
31-
if path == "." {
32-
path = ""
33-
}
34-
35-
return &executor.Task{
36-
Repository: workspace.Repo,
37-
Path: path,
38-
Steps: workspace.Steps,
39-
OnlyFetchWorkspace: workspace.OnlyFetchWorkspace,
40-
41-
TransformChanges: spec.TransformChanges,
42-
Template: spec.ChangesetTemplate,
43-
BatchChangeAttributes: &batchChange,
44-
}
45-
}

internal/batches/service/service.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,11 +681,16 @@ func (svc *Service) FindDirectoriesInRepos(ctx context.Context, fileName string,
681681

682682
var dirs []string
683683
for f := range files {
684+
dir := path.Dir(f)
685+
// "." means the path is root, but in the executor we use "" to signify root.
686+
if dir == "." {
687+
dir = ""
688+
}
684689
// We use path.Dir and not filepath.Dir here, because while
685690
// src-cli might be executed on Windows, we need the paths to
686691
// be Unix paths, since they will be used inside Docker
687692
// containers.
688-
dirs = append(dirs, path.Dir(f))
693+
dirs = append(dirs, dir)
689694
}
690695

691696
results[repo] = dirs

internal/batches/service/service_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ func TestService_FindDirectoriesInRepos(t *testing.T) {
364364

365365
want := map[*graphql.Repository][]string{
366366
repos[0]: {"examples/project3", "project1", "project2"},
367-
repos[1]: {"docs/client1", ".", "docs/client2/examples"},
367+
repos[1]: {"docs/client1", "", "docs/client2/examples"},
368368
}
369369

370370
if !cmp.Equal(want, results, cmpopts.SortSlices(sortStrings)) {

0 commit comments

Comments
 (0)