Skip to content

Commit

Permalink
populate branch name during template resolution (#1054)
Browse files Browse the repository at this point in the history
  • Loading branch information
camdencheek authored Jan 1, 2024
1 parent d53e95f commit 0621a63
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions internal/batches/executor/run_steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,12 @@ func RunSteps(ctx context.Context, opts *RunStepsOpts) (stepResults []execution.

stepContext := template.StepContext{
BatchChange: *opts.Task.BatchChangeAttributes,
Repository: util.NewTemplatingRepo(opts.Task.Repository.Name, opts.Task.Repository.FileMatches),
Outputs: lastOutputs,
Repository: util.NewTemplatingRepo(
opts.Task.Repository.Name,
opts.Task.Repository.Branch.Name,
opts.Task.Repository.FileMatches,
),
Outputs: lastOutputs,
Steps: template.StepsContext{
Path: opts.Task.Path,
Changes: previousStepResult.ChangedFiles,
Expand Down
3 changes: 2 additions & 1 deletion internal/batches/util/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ import (

// NewTemplatingRepo transforms a given *graphql.Repository into a
// template.Repository.
func NewTemplatingRepo(repoName string, fileMatches map[string]bool) template.Repository {
func NewTemplatingRepo(repoName string, branch string, fileMatches map[string]bool) template.Repository {
matches := make([]string, 0, len(fileMatches))
for path := range fileMatches {
matches = append(matches, path)
}
return template.Repository{
Name: repoName,
Branch: branch,
FileMatches: matches,
}
}
Expand Down

0 comments on commit 0621a63

Please sign in to comment.