mirror of
https://github.com/harness/drone.git
synced 2025-05-04 14:12:15 +08:00
add log entries for rejected merges (#2604)
* add log entries for rejected merges
This commit is contained in:
parent
ffe585f8c4
commit
6b12b45950
@ -130,7 +130,7 @@ func (c *Controller) Merge(
|
|||||||
timeout+30*time.Second, // add 30s to the lock to give enough time for pre + post merge
|
timeout+30*time.Second, // add 30s to the lock to give enough time for pre + post merge
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, fmt.Errorf("failed to lock repository for pull request merge: %w", err)
|
||||||
}
|
}
|
||||||
defer unlock()
|
defer unlock()
|
||||||
|
|
||||||
@ -310,6 +310,24 @@ func (c *Controller) Merge(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if protection.IsCritical(violations) {
|
if protection.IsCritical(violations) {
|
||||||
|
sb := strings.Builder{}
|
||||||
|
for i, ruleViolation := range violations {
|
||||||
|
if i > 0 {
|
||||||
|
sb.WriteByte(',')
|
||||||
|
}
|
||||||
|
sb.WriteString(ruleViolation.Rule.Identifier)
|
||||||
|
sb.WriteString(":[")
|
||||||
|
for j, v := range ruleViolation.Violations {
|
||||||
|
if j > 0 {
|
||||||
|
sb.WriteByte(',')
|
||||||
|
}
|
||||||
|
sb.WriteString(v.Code)
|
||||||
|
}
|
||||||
|
sb.WriteString("]")
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Ctx(ctx).Info().Msgf("aborting pull request merge because of rule violations: %s", sb.String())
|
||||||
|
|
||||||
return nil, &types.MergeViolations{RuleViolations: violations}, nil
|
return nil, &types.MergeViolations{RuleViolations: violations}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -401,6 +419,8 @@ func (c *Controller) Merge(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Ctx(ctx).Info().Msg("aborting pull request merge because of conflicts")
|
||||||
|
|
||||||
return nil, &types.MergeViolations{
|
return nil, &types.MergeViolations{
|
||||||
ConflictFiles: mergeOutput.ConflictFiles,
|
ConflictFiles: mergeOutput.ConflictFiles,
|
||||||
RuleViolations: violations,
|
RuleViolations: violations,
|
||||||
|
Loading…
Reference in New Issue
Block a user