Skip to content

Commit 2fb34b6

Browse files
authored
Use latest lib (#657)
1 parent 107564e commit 2fb34b6

3 files changed

Lines changed: 26 additions & 37 deletions

File tree

cmd/src/batch_exec.go

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ func executeBatchSpecInWorkspaces(ctx context.Context, ui *ui.JSONLines, opts ex
105105
return err
106106
}
107107

108-
// Since we already know which workspaces we want to execute the steps in,
109-
// we can convert them to RepoWorkspaces and build tasks only for those.
110-
repoWorkspaces := convertWorkspaces(input.Workspaces)
108+
// Since we already know which workspace we want to execute the steps in,
109+
// we can convert it to a RepoWorkspace and build a task only for that one.
110+
repoWorkspace := convertWorkspace(input.Workspace)
111111

112112
// Parse the raw batch spec contained in the input
113113
ui.ParsingBatchSpec()
@@ -162,7 +162,7 @@ func executeBatchSpecInWorkspaces(ctx context.Context, ui *ui.JSONLines, opts ex
162162
// `src batch exec` uses server-side caching for changeset specs, so we
163163
// only need to call `CheckStepResultsCache` to make sure that per-step cache entries
164164
// are loaded and set on the tasks.
165-
tasks := svc.BuildTasks(ctx, batchSpec, repoWorkspaces)
165+
tasks := svc.BuildTasks(ctx, batchSpec, []service.RepoWorkspace{repoWorkspace})
166166
if err := coord.CheckStepResultsCache(ctx, tasks); err != nil {
167167
return err
168168
}
@@ -218,33 +218,26 @@ func loadWorkspaceExecutionInput(file string) (batcheslib.WorkspacesExecutionInp
218218
return input, nil
219219
}
220220

221-
func convertWorkspaces(ws []*batcheslib.Workspace) []service.RepoWorkspace {
222-
workspaces := make([]service.RepoWorkspace, 0, len(ws))
223-
224-
for _, w := range ws {
225-
fileMatches := make(map[string]bool)
226-
for _, path := range w.SearchResultPaths {
227-
fileMatches[path] = true
228-
}
229-
230-
workspaces = append(workspaces, service.RepoWorkspace{
231-
Repo: &graphql.Repository{
232-
ID: w.Repository.ID,
233-
Name: w.Repository.Name,
234-
Branch: graphql.Branch{
235-
Name: w.Branch.Name,
236-
Target: graphql.Target{
237-
OID: w.Branch.Target.OID,
238-
},
221+
func convertWorkspace(w batcheslib.Workspace) service.RepoWorkspace {
222+
fileMatches := make(map[string]bool)
223+
for _, path := range w.SearchResultPaths {
224+
fileMatches[path] = true
225+
}
226+
return service.RepoWorkspace{
227+
Repo: &graphql.Repository{
228+
ID: w.Repository.ID,
229+
Name: w.Repository.Name,
230+
Branch: graphql.Branch{
231+
Name: w.Branch.Name,
232+
Target: graphql.Target{
233+
OID: w.Branch.Target.OID,
239234
},
240-
Commit: graphql.Target{OID: w.Branch.Target.OID},
241-
FileMatches: fileMatches,
242235
},
243-
Path: w.Path,
244-
Steps: w.Steps,
245-
OnlyFetchWorkspace: w.OnlyFetchWorkspace,
246-
})
236+
Commit: graphql.Target{OID: w.Branch.Target.OID},
237+
FileMatches: fileMatches,
238+
},
239+
Path: w.Path,
240+
Steps: w.Steps,
241+
OnlyFetchWorkspace: w.OnlyFetchWorkspace,
247242
}
248-
249-
return workspaces
250243
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ require (
2020
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4
2121
github.com/sourcegraph/go-diff v0.6.1
2222
github.com/sourcegraph/jsonx v0.0.0-20200629203448-1a936bd500cf
23-
github.com/sourcegraph/sourcegraph/lib v0.0.0-20211111140427-2e938231dac5
23+
github.com/sourcegraph/sourcegraph/lib v0.0.0-20211115102128-3c8c7a9499a3
2424
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf // indirect
2525
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
2626
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d

go.sum

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,8 @@ github.com/sourcegraph/go-diff v0.6.1 h1:hmA1LzxW0n1c3Q4YbrFgg4P99GSnebYa3x8gr0H
258258
github.com/sourcegraph/go-diff v0.6.1/go.mod h1:iBszgVvyxdc8SFZ7gm69go2KDdt3ag071iBaWPF6cjs=
259259
github.com/sourcegraph/jsonx v0.0.0-20200629203448-1a936bd500cf h1:oAdWFqhStsWiiMP/vkkHiMXqFXzl1XfUNOdxKJbd6bI=
260260
github.com/sourcegraph/jsonx v0.0.0-20200629203448-1a936bd500cf/go.mod h1:ppFaPm6kpcHnZGqQTFhUIAQRIEhdQDWP1PCv4/ON354=
261-
github.com/sourcegraph/sourcegraph/lib v0.0.0-20211109155204-31a95b8405e0 h1:NaYWQFsArbbSysPHyPC0jChFqlrQg01pVz5ej5X393Q=
262-
github.com/sourcegraph/sourcegraph/lib v0.0.0-20211109155204-31a95b8405e0/go.mod h1:4WdX5odo9YL0GD0Wg9OZJJtIJIn1jIsh+UWrQ4MEcaw=
263-
github.com/sourcegraph/sourcegraph/lib v0.0.0-20211111132504-9eca3a9ea27b h1:MIeeeFbOmIbjpLEcc5KYfs6tsCBecwFuZWxV8Om+PFw=
264-
github.com/sourcegraph/sourcegraph/lib v0.0.0-20211111132504-9eca3a9ea27b/go.mod h1:4WdX5odo9YL0GD0Wg9OZJJtIJIn1jIsh+UWrQ4MEcaw=
265-
github.com/sourcegraph/sourcegraph/lib v0.0.0-20211111140427-2e938231dac5 h1:Ome/BYdr0lrwMCPseJUYI0uzv45TVVnfPJ5/DP367wg=
266-
github.com/sourcegraph/sourcegraph/lib v0.0.0-20211111140427-2e938231dac5/go.mod h1:4WdX5odo9YL0GD0Wg9OZJJtIJIn1jIsh+UWrQ4MEcaw=
261+
github.com/sourcegraph/sourcegraph/lib v0.0.0-20211115102128-3c8c7a9499a3 h1:vaflMp94dFzfdgb2MIxGEVQKo1O1o3uH9w0sYds/ZBU=
262+
github.com/sourcegraph/sourcegraph/lib v0.0.0-20211115102128-3c8c7a9499a3/go.mod h1:4WdX5odo9YL0GD0Wg9OZJJtIJIn1jIsh+UWrQ4MEcaw=
267263
github.com/sourcegraph/yaml v1.0.1-0.20200714132230-56936252f152 h1:z/MpntplPaW6QW95pzcAR/72Z5TWDyDnSo0EOcyij9o=
268264
github.com/sourcegraph/yaml v1.0.1-0.20200714132230-56936252f152/go.mod h1:GIjDIg/heH5DOkXY3YJ/wNhfHsQHoXGjl8G8amsYQ1I=
269265
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=

0 commit comments

Comments
 (0)