Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ require (
github.com/sourcegraph/batch-change-utils v0.0.0-20210708162152-c9f35b905d94
github.com/sourcegraph/go-diff v0.6.1
github.com/sourcegraph/jsonx v0.0.0-20200629203448-1a936bd500cf
github.com/sourcegraph/sourcegraph/lib v0.0.0-20210831122102-a95181f49527
github.com/sourcegraph/sourcegraph/lib v0.0.0-20210901132614-5780c9c4b466
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
golang.org/x/net v0.0.0-20210614182718-04defd469f4e
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ github.com/sourcegraph/go-diff v0.6.1 h1:hmA1LzxW0n1c3Q4YbrFgg4P99GSnebYa3x8gr0H
github.com/sourcegraph/go-diff v0.6.1/go.mod h1:iBszgVvyxdc8SFZ7gm69go2KDdt3ag071iBaWPF6cjs=
github.com/sourcegraph/jsonx v0.0.0-20200629203448-1a936bd500cf h1:oAdWFqhStsWiiMP/vkkHiMXqFXzl1XfUNOdxKJbd6bI=
github.com/sourcegraph/jsonx v0.0.0-20200629203448-1a936bd500cf/go.mod h1:ppFaPm6kpcHnZGqQTFhUIAQRIEhdQDWP1PCv4/ON354=
github.com/sourcegraph/sourcegraph/lib v0.0.0-20210831122102-a95181f49527 h1:Bj2XOghFkSnxE0EcpmtmjIFbqDkJ0wBNTvM6cguKaKs=
github.com/sourcegraph/sourcegraph/lib v0.0.0-20210831122102-a95181f49527/go.mod h1:aH/URdfJ92i5Ec/5u2GSlliMZtKzsD91oTJNwZpH8Hc=
github.com/sourcegraph/sourcegraph/lib v0.0.0-20210901132614-5780c9c4b466 h1:hyo3Vr63aieMyWqrfy0skzZHT3ACjajrd3ksVxmMl7k=
github.com/sourcegraph/sourcegraph/lib v0.0.0-20210901132614-5780c9c4b466/go.mod h1:lSNpzAxCBx40MpkM/DbMH7ZUMURcpAstABzhbc4O5V8=
github.com/sourcegraph/yaml v1.0.1-0.20200714132230-56936252f152 h1:z/MpntplPaW6QW95pzcAR/72Z5TWDyDnSo0EOcyij9o=
github.com/sourcegraph/yaml v1.0.1-0.20200714132230-56936252f152/go.mod h1:GIjDIg/heH5DOkXY3YJ/wNhfHsQHoXGjl8G8amsYQ1I=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
Expand Down
3 changes: 2 additions & 1 deletion internal/batches/executor/changeset_specs.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
batcheslib "github.com/sourcegraph/sourcegraph/lib/batches"
"github.com/sourcegraph/src-cli/internal/batches"
"github.com/sourcegraph/src-cli/internal/batches/template"
"github.com/sourcegraph/src-cli/internal/batches/util"
)

var errOptionalPublishedUnsupported = errors.New(`This Sourcegraph version requires the "published" field to be specified in the batch spec; upgrade to version 3.30.0 or later to be able to omit the published field and control publication from the UI.`)
Expand All @@ -23,7 +24,7 @@ func createChangesetSpecs(task *Task, result executionResult, features batches.F
Path: result.Path,
},
Outputs: result.Outputs,
Repository: *task.Repository,
Repository: util.GraphQLRepoToTemplatingRepo(task.Repository),
}

var authorName string
Expand Down
2 changes: 1 addition & 1 deletion internal/batches/executor/changeset_specs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/mitchellh/copystructure"
"github.com/sourcegraph/batch-change-utils/overridable"
batcheslib "github.com/sourcegraph/sourcegraph/lib/batches"
"github.com/sourcegraph/sourcegraph/lib/batches/git"
"github.com/sourcegraph/src-cli/internal/batches"
"github.com/sourcegraph/src-cli/internal/batches/git"
"github.com/sourcegraph/src-cli/internal/batches/template"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/batches/executor/coordinator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/sourcegraph/batch-change-utils/overridable"
batcheslib "github.com/sourcegraph/sourcegraph/lib/batches"
"github.com/sourcegraph/src-cli/internal/batches/git"
"github.com/sourcegraph/sourcegraph/lib/batches/git"
"github.com/sourcegraph/src-cli/internal/batches/graphql"
"github.com/sourcegraph/src-cli/internal/batches/mock"
"github.com/sourcegraph/src-cli/internal/batches/template"
Expand Down
2 changes: 1 addition & 1 deletion internal/batches/executor/execution_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/google/go-cmp/cmp"
batcheslib "github.com/sourcegraph/sourcegraph/lib/batches"
"github.com/sourcegraph/src-cli/internal/batches/git"
"github.com/sourcegraph/sourcegraph/lib/batches/git"
"gopkg.in/yaml.v3"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/batches/executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import (
"github.com/pkg/errors"
"github.com/sourcegraph/go-diff/diff"
batcheslib "github.com/sourcegraph/sourcegraph/lib/batches"
"github.com/sourcegraph/sourcegraph/lib/batches/git"
"github.com/sourcegraph/src-cli/internal/api"
"github.com/sourcegraph/src-cli/internal/batches"
"github.com/sourcegraph/src-cli/internal/batches/docker"
"github.com/sourcegraph/src-cli/internal/batches/git"
"github.com/sourcegraph/src-cli/internal/batches/mock"
"github.com/sourcegraph/src-cli/internal/batches/template"
"github.com/sourcegraph/src-cli/internal/batches/workspace"
Expand Down
5 changes: 3 additions & 2 deletions internal/batches/executor/run_steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ import (
"github.com/hashicorp/go-multierror"
"github.com/pkg/errors"
batcheslib "github.com/sourcegraph/sourcegraph/lib/batches"
"github.com/sourcegraph/src-cli/internal/batches/git"
"github.com/sourcegraph/sourcegraph/lib/batches/git"
"github.com/sourcegraph/src-cli/internal/batches/log"
"github.com/sourcegraph/src-cli/internal/batches/template"
"github.com/sourcegraph/src-cli/internal/batches/util"
"github.com/sourcegraph/src-cli/internal/batches/workspace"

yamlv3 "gopkg.in/yaml.v3"
Expand Down Expand Up @@ -125,7 +126,7 @@ func runSteps(ctx context.Context, opts *executionOpts) (result executionResult,

stepContext := template.StepContext{
BatchChange: *opts.task.BatchChangeAttributes,
Repository: *opts.task.Repository,
Repository: util.GraphQLRepoToTemplatingRepo(opts.task.Repository),
Outputs: execResult.Outputs,
Steps: template.StepsContext{
Path: execResult.Path,
Expand Down
1 change: 0 additions & 1 deletion internal/batches/features_test.go

This file was deleted.

73 changes: 0 additions & 73 deletions internal/batches/git/changes.go

This file was deleted.

80 changes: 0 additions & 80 deletions internal/batches/git/changes_test.go

This file was deleted.

14 changes: 0 additions & 14 deletions internal/batches/graphql/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package graphql
import (
"crypto/sha256"
"encoding/base64"
"sort"
"strings"
)

Expand Down Expand Up @@ -93,16 +92,3 @@ func (r *Repository) SlugForPath(path string) string {
}
return strings.ReplaceAll(name, "/", "-") + "-" + r.Rev()
}

func (r *Repository) SearchResultPaths() (list fileMatchPathList) {
var files []string
for f := range r.FileMatches {
files = append(files, f)
}
sort.Strings(files)
return fileMatchPathList(files)
}

type fileMatchPathList []string

func (f fileMatchPathList) String() string { return strings.Join(f, " ") }
26 changes: 13 additions & 13 deletions internal/batches/service/build_tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/sourcegraph/src-cli/internal/batches/executor"
"github.com/sourcegraph/src-cli/internal/batches/graphql"
"github.com/sourcegraph/src-cli/internal/batches/template"
"github.com/sourcegraph/src-cli/internal/batches/util"
)

// buildTasks returns tasks for all the workspaces determined for the given spec.
Expand Down Expand Up @@ -37,21 +38,23 @@ func buildTasks(ctx context.Context, spec *batcheslib.BatchSpec, repos []*graphq
}

func buildTask(spec *batcheslib.BatchSpec, r *graphql.Repository, path string, onlyWorkspace bool) (*executor.Task, bool, error) {
stepCtx := &template.StepContext{
Repository: *r,
BatchChange: template.BatchChangeAttributes{
Name: spec.Name,
Description: spec.Description,
},
batchChange := template.BatchChangeAttributes{
Name: spec.Name,
Description: spec.Description,
}

var taskSteps []batcheslib.Step
taskSteps := []batcheslib.Step{}
for _, step := range spec.Steps {
// If no if condition is given, just go ahead and add the step to the list.
if step.IfCondition() == "" {
taskSteps = append(taskSteps, step)
continue
}

stepCtx := &template.StepContext{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need a fresh template.StepContext in every iteration?

Repository: util.GraphQLRepoToTemplatingRepo(r),
BatchChange: batchChange,
}
static, boolVal, err := template.IsStaticBool(step.IfCondition(), stepCtx)
if err != nil {
return nil, false, err
Expand Down Expand Up @@ -82,11 +85,8 @@ func buildTask(spec *batcheslib.BatchSpec, r *graphql.Repository, path string, o
Steps: taskSteps,
OnlyFetchWorkspace: onlyWorkspace,

TransformChanges: spec.TransformChanges,
Template: spec.ChangesetTemplate,
BatchChangeAttributes: &template.BatchChangeAttributes{
Name: spec.Name,
Description: spec.Description,
},
TransformChanges: spec.TransformChanges,
Template: spec.ChangesetTemplate,
BatchChangeAttributes: &batchChange,
}, true, nil
}
6 changes: 2 additions & 4 deletions internal/batches/template/main_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package template

import "github.com/sourcegraph/src-cli/internal/batches/graphql"

var testRepo1 = &graphql.Repository{
var testRepo1 = &TemplatingRepository{
ID: "src-cli",
Name: "github.com/sourcegraph/src-cli",
DefaultBranch: &graphql.Branch{Name: "main", Target: graphql.Target{OID: "d34db33f"}},
DefaultBranch: TemplatingBranch{Name: "main", TargetOID: "d34db33f"},
FileMatches: map[string]bool{
"README.md": true,
"main.go": true,
Expand Down
3 changes: 1 addition & 2 deletions internal/batches/template/partial_eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"testing"

"github.com/google/go-cmp/cmp"
"github.com/sourcegraph/src-cli/internal/batches/graphql"
)

var partialEvalStepCtx = &StepContext{
Expand All @@ -13,7 +12,7 @@ var partialEvalStepCtx = &StepContext{
Description: "test-description",
},
// Step is not set when evalStepCondition is called
Repository: graphql.Repository{
Repository: TemplatingRepository{
Name: "github.com/sourcegraph/src-cli",
FileMatches: map[string]bool{
"README.md": true,
Expand Down
Loading