mirror of
https://github.com/harness/drone.git
synced 2025-05-04 13:22:13 +08:00
return want&got for rule violations (#704)
This commit is contained in:
parent
adeb965723
commit
02b36d0f73
@ -101,8 +101,9 @@ func (v *Branch) CanMerge(_ context.Context, in CanMergeInput) (CanMergeOutput,
|
||||
|
||||
if len(v.PullReq.Merge.StrategiesAllowed) > 0 { // Note: Empty allowed strategies list means all are allowed
|
||||
if !slices.Contains(v.PullReq.Merge.StrategiesAllowed, in.Method) {
|
||||
violations.Add("pullreq.merge.strategies_allowed",
|
||||
"The requested merge strategy is not allowed.")
|
||||
violations.Addf("pullreq.merge.strategies_allowed",
|
||||
"The requested merge strategy %q is not allowed. Allowed strategies are %v.",
|
||||
in.Method, v.PullReq.Merge.StrategiesAllowed)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,6 +57,7 @@ type RuleFilter struct {
|
||||
type Violation struct {
|
||||
Code string `json:"code"`
|
||||
Message string `json:"message"`
|
||||
Params []any `json:"params"`
|
||||
}
|
||||
|
||||
// RuleViolations holds several violations of a rule.
|
||||
@ -69,6 +70,7 @@ func (violations *RuleViolations) Add(code, message string) {
|
||||
violations.Violations = append(violations.Violations, Violation{
|
||||
Code: code,
|
||||
Message: message,
|
||||
Params: nil,
|
||||
})
|
||||
}
|
||||
|
||||
@ -76,6 +78,7 @@ func (violations *RuleViolations) Addf(code, format string, params ...any) {
|
||||
violations.Violations = append(violations.Violations, Violation{
|
||||
Code: code,
|
||||
Message: fmt.Sprintf(format, params...),
|
||||
Params: params,
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user