Skip to content

Commit 99ea22d

Browse files
committed
Remove shortcuts in templates for now
1 parent e44442c commit 99ea22d

File tree

4 files changed

+8
-29
lines changed

4 files changed

+8
-29
lines changed

internal/campaigns/executor_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func TestExecutor_Integration(t *testing.T) {
104104
},
105105
steps: []Step{
106106
{Run: `go fmt main.go`, Container: "doesntmatter:13"},
107-
{Run: `touch modified-${{ modified_files }}.md`, Container: "alpine:13"},
107+
{Run: `touch modified-${{ .PreviousStep.ModifiedFiles }}.md`, Container: "alpine:13"},
108108
},
109109
wantFilesChanged: map[string][]string{
110110
srcCLIRepo.ID: []string{"main.go", "modified-main.go.md"},

internal/campaigns/graphql/repository.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,13 @@ func (r *Repository) Slug() string {
4646
return strings.ReplaceAll(r.Name, "/", "-")
4747
}
4848

49-
func (r *Repository) FileMatchPaths() string {
50-
files := []string{}
49+
func (r *Repository) SearchResultPaths() (list fileMatchPathList) {
5150
for f := range r.FileMatches {
52-
files = append(files, f)
51+
list = append(list, f)
5352
}
54-
return strings.Join(files, " ")
53+
return list
5554
}
5655

5756
type fileMatchPathList []string
5857

5958
func (f fileMatchPathList) String() string { return strings.Join(f, " ") }
60-
61-
func (r *Repository) FileMatchPathList() (list fileMatchPathList) {
62-
for f := range r.FileMatches {
63-
list = append(list, f)
64-
}
65-
return list
66-
}

internal/campaigns/run_steps.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -188,20 +188,7 @@ func runSteps(ctx context.Context, wc *WorkspaceCreator, repo *graphql.Repositor
188188
}
189189

190190
func parseStepRun(stepCtx StepContext, run string) (*template.Template, error) {
191-
t := template.New("step-run").Delims("${{", "}}")
192-
193-
funcMap := template.FuncMap{
194-
"repository_name": func() string { return stepCtx.Repository.Name },
195-
"search_results": stepCtx.Repository.FileMatchPathList,
196-
"search_result_list": stepCtx.Repository.FileMatchPathList,
197-
"join": func(sl []string, sep string) string { return strings.Join(sl, sep) },
198-
}
199-
200-
funcMap["modified_files"] = stepCtx.PreviousStep.ModifiedFiles
201-
202-
t.Funcs(funcMap)
203-
204-
return t.Parse(run)
191+
return template.New("step-run").Delims("${{", "}}").Parse(run)
205192
}
206193

207194
type StepContext struct {

internal/campaigns/run_steps_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ func TestParseStepRun(t *testing.T) {
4949
},
5050
},
5151

52-
run: `${{ modified_files }} ${{ repository_name }}`,
52+
run: `${{ .PreviousStep.ModifiedFiles }} ${{ .Repository.Name }}`,
5353
want: `go.mod github.com/sourcegraph/src-cli`,
5454
},
5555
{
5656
stepCtx: StepContext{
5757
Repository: &graphql.Repository{Name: "github.com/sourcegraph/src-cli"},
5858
},
5959

60-
run: `${{ modified_files }} ${{ repository_name }}`,
60+
run: `${{ .PreviousStep.ModifiedFiles }} ${{ .Repository.Name }}`,
6161
want: ` github.com/sourcegraph/src-cli`,
6262
},
6363
{
@@ -71,7 +71,7 @@ func TestParseStepRun(t *testing.T) {
7171
},
7272
},
7373

74-
run: `${{ search_results }}`,
74+
run: `${{ .Repository.SearchResultPaths }}`,
7575
want: `README.md main.go`,
7676
},
7777
}

0 commit comments

Comments
 (0)