Skip to content

Commit 40eaec7

Browse files
authored
Merge pull request #16 from mercari/fix-context-message
Fix context message
2 parents 1fd92a3 + 256d521 commit 40eaec7

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

server/handler/eval_context.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,7 @@ func (ec *EvalContext) PostStatus(ctx context.Context, state, message string) {
183183
publicURL := strings.TrimSuffix(ec.PublicURL, "/")
184184
detailsURL := fmt.Sprintf("%s/details/%s/%s/%d", publicURL, owner, repo, ec.PullContext.Number())
185185

186-
var context string
187-
if !ec.Options.StatusCheckContextIgnoreBase {
188-
context = fmt.Sprintf("%s: %s", ec.Options.StatusCheckContext, base)
189-
} else {
190-
context = ec.Options.StatusCheckContext
191-
}
186+
context := ec.Options.StatusCheckContextWithBranch(base)
192187

193188
var prefix string
194189
switch state {

server/handler/eval_options.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package handler
1616

1717
import (
18+
"fmt"
1819
"os"
1920
"strconv"
2021
)
@@ -87,6 +88,13 @@ type PullEvaluationOptions struct {
8788
Deprecated_DoNotLoadCommitPushedDate bool `yaml:"do_not_load_commit_pushed_date"`
8889
}
8990

91+
func (p *PullEvaluationOptions) StatusCheckContextWithBranch(baseBranch string) string {
92+
if p.StatusCheckContextIgnoreBase {
93+
return p.StatusCheckContext
94+
}
95+
return fmt.Sprintf("%s: %s", p.StatusCheckContext, baseBranch)
96+
}
97+
9098
func (p *PullEvaluationOptions) fillDefaults() {
9199
if p.PolicyPath == "" {
92100
p.PolicyPath = DefaultPolicyPath

server/handler/installation.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ func (h *Installation) postRepoInstallationStatus(ctx context.Context, client *g
9898
}
9999

100100
head := branch.GetCommit().GetSHA()
101-
contextWithBranch := fmt.Sprintf("%s: %s", h.PullOpts.StatusCheckContext, defaultBranch)
101+
102+
contextWithBranch := h.PullOpts.StatusCheckContextWithBranch(defaultBranch)
102103
state := "success"
103104
message := fmt.Sprintf("%s successfully installed.", h.AppName)
104105
status := &github.RepoStatus{

server/handler/merge_group.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func (h *MergeGroup) Handle(ctx context.Context, eventType, devlieryID string, p
6565
return nil
6666
}
6767

68-
contextWithBranch := fmt.Sprintf("%s: %s", h.PullOpts.StatusCheckContext, baseBranch)
68+
contextWithBranch := h.PullOpts.StatusCheckContextWithBranch(baseBranch)
6969
state := "success"
7070
message := fmt.Sprintf("%s previously approved original pull request.", h.AppName)
7171
status := &github.RepoStatus{

0 commit comments

Comments
 (0)