From 0603017ceea0268c9efdb88bfea3d2c2c99e43f6 Mon Sep 17 00:00:00 2001 From: Jashandeep Sohi Date: Mon, 5 Aug 2024 05:32:45 -0700 Subject: [PATCH] allow templates in --pr-merge-commit-title & --pr-merge-commit-message (#345) * allow templates in --pr-merge-commit-title & --pr-merge-commit-message * lint --------- Co-authored-by: Vincent Behar --- repository/options.go | 12 ++++++++++++ repository/repository.go | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/repository/options.go b/repository/options.go index d0a9c60f..23b62c83 100644 --- a/repository/options.go +++ b/repository/options.go @@ -198,6 +198,18 @@ func (o *GitHubOptions) setDefaultValues(git GitOptions, tplExecutorFunc templat } o.PullRequest.Body = prBody + prMergeCommitTitle, err := tplExecutorFunc(o.PullRequest.Merge.CommitTitle) + if err != nil { + return fmt.Errorf("failed to run template for pull request merge commit title %s: %w", o.PullRequest.Merge.CommitTitle, err) + } + o.PullRequest.Merge.CommitTitle = prMergeCommitTitle + + prMergeCommitMessage, err := tplExecutorFunc(o.PullRequest.Merge.CommitMessage) + if err != nil { + return fmt.Errorf("failed to run template for pull request merge commit message %s: %w", o.PullRequest.Merge.CommitMessage, err) + } + o.PullRequest.Merge.CommitMessage = prMergeCommitMessage + return nil } diff --git a/repository/repository.go b/repository/repository.go index 27999c1a..735d99e7 100644 --- a/repository/repository.go +++ b/repository/repository.go @@ -162,7 +162,7 @@ func (r Repository) Update(ctx context.Context, updaters []update.Updater, optio return true, pr, nil } - err = r.mergePullRequest(ctx, options.GitHub, pr) + err = r.mergePullRequest(ctx, strategy.Options.GitHub, pr) if err != nil { return true, pr, fmt.Errorf("failed to merge Pull Request %s: %w", pr.GetHTMLURL(), err) }