@@ -16,7 +16,6 @@ import (
1616 "github.com/pkg/errors"
1717 "github.com/sourcegraph/src-cli/internal/batches"
1818 "github.com/sourcegraph/src-cli/internal/batches/git"
19- "github.com/sourcegraph/src-cli/internal/batches/graphql"
2019 "github.com/sourcegraph/src-cli/internal/batches/log"
2120 "github.com/sourcegraph/src-cli/internal/batches/workspace"
2221
@@ -54,53 +53,43 @@ type executionResult struct {
5453}
5554
5655type executionOpts struct {
57- archive batches. RepoZip
56+ wc workspace. Creator
5857
59- wc workspace.Creator
60- path string
61-
62- batchChangeAttributes * BatchChangeAttributes
63- repo * graphql.Repository
64- steps []batches.Step
58+ task * Task
6559
6660 tempDir string
6761
6862 logger log.TaskLogger
6963 reportProgress func (string )
70-
71- // cachedResultFound determines whether all steps are executed or only
72- // steps >= cachedResult.Step.
73- cachedResultFound bool
74- cachedResult stepExecutionResult
7564}
7665
7766func runSteps (ctx context.Context , opts * executionOpts ) (result executionResult , stepResults []stepExecutionResult , err error ) {
7867 opts .reportProgress ("Downloading archive" )
79- err = opts .archive .Fetch (ctx )
68+ err = opts .task . Archive .Fetch (ctx )
8069 if err != nil {
8170 return executionResult {}, nil , errors .Wrap (err , "fetching repo" )
8271 }
83- defer opts .archive .Close ()
72+ defer opts .task . Archive .Close ()
8473
8574 opts .reportProgress ("Initializing workspace" )
86- workspace , err := opts .wc .Create (ctx , opts .repo , opts .steps , opts .archive )
75+ workspace , err := opts .wc .Create (ctx , opts .task . Repository , opts .task . Steps , opts .task . Archive )
8776 if err != nil {
8877 return executionResult {}, nil , errors .Wrap (err , "creating workspace" )
8978 }
9079 defer workspace .Close (ctx )
9180
9281 execResult := executionResult {
9382 Outputs : make (map [string ]interface {}),
94- Path : opts .path ,
83+ Path : opts .task . Path ,
9584 }
96- results := make ([]StepResult , len (opts .steps ))
85+ results := make ([]StepResult , len (opts .task . Steps ))
9786
9887 var startStep int
99- if opts .cachedResultFound {
88+ if opts .task . CachedResultFound {
10089 // Set the Outputs to the cached outputs
101- execResult .Outputs = opts .cachedResult .Outputs
90+ execResult .Outputs = opts .task . CachedResult .Outputs
10291
103- startStep = opts .cachedResult .StepIndex + 1
92+ startStep = opts .task . CachedResult .StepIndex + 1
10493
10594 switch startStep {
10695 case 1 :
@@ -112,25 +101,25 @@ func runSteps(ctx context.Context, opts *executionOpts) (result executionResult,
112101 startStep = 0
113102 }
114103
115- for i := startStep ; i < len (opts .steps ); i ++ {
116- step := opts .steps [i ]
104+ for i := startStep ; i < len (opts .task . Steps ); i ++ {
105+ step := opts .task . Steps [i ]
117106
118107 stepContext := StepContext {
119- BatchChange : * opts .batchChangeAttributes ,
120- Repository : * opts .repo ,
108+ BatchChange : * opts .task . BatchChangeAttributes ,
109+ Repository : * opts .task . Repository ,
121110 Outputs : execResult .Outputs ,
122111 Steps : StepsContext {
123112 Path : execResult .Path ,
124113 },
125114 }
126115
127- if opts .cachedResultFound && i == startStep {
128- if err := workspace .ApplyDiff (ctx , []byte (opts .cachedResult .Diff )); err != nil {
116+ if opts .task . CachedResultFound && i == startStep {
117+ if err := workspace .ApplyDiff (ctx , []byte (opts .task . CachedResult .Diff )); err != nil {
129118 return execResult , nil , errors .Wrap (err , "getting changed files in step" )
130119 }
131120
132- results [i - 1 ] = opts .cachedResult .PreviousStepResult
133- stepContext .Outputs = opts .cachedResult .Outputs
121+ results [i - 1 ] = opts .task . CachedResult .PreviousStepResult
122+ stepContext .Outputs = opts .task . CachedResult .Outputs
134123 }
135124
136125 if i > 0 {
@@ -152,7 +141,7 @@ func runSteps(ctx context.Context, opts *executionOpts) (result executionResult,
152141 // Find a location that we can use for a cidfile, which will contain the
153142 // container ID that is used below. We can then use this to remove the
154143 // container on a successful run, rather than leaving it dangling.
155- cidFile , err := ioutil .TempFile (opts .tempDir , opts .repo .Slug ()+ "-container-id" )
144+ cidFile , err := ioutil .TempFile (opts .tempDir , opts .task . Repository .Slug ()+ "-container-id" )
156145 if err != nil {
157146 return execResult , nil , errors .Wrap (err , "Creating a CID file failed" )
158147 }
@@ -270,8 +259,8 @@ func runSteps(ctx context.Context, opts *executionOpts) (result executionResult,
270259
271260 // Where should we execute the steps.run script?
272261 scriptWorkDir := workDir
273- if opts .path != "" {
274- scriptWorkDir = workDir + "/" + opts .path
262+ if opts .task . Path != "" {
263+ scriptWorkDir = workDir + "/" + opts .task . Path
275264 }
276265
277266 args := append ([]string {
0 commit comments