fix branch.lifecycle rule violation codes (#719)

This commit is contained in:
Marko Gacesa 2023-10-25 12:16:47 +00:00 committed by Harness
parent 66ac5e3a5c
commit fda8fa733d

View File

@ -119,17 +119,17 @@ func (v *Branch) CanModifyRef(_ context.Context, in CanModifyRefInput) ([]types.
switch in.RefAction { switch in.RefAction {
case RefActionCreate: case RefActionCreate:
if v.Lifecycle.CreateForbidden { if v.Lifecycle.CreateForbidden {
violations.Addf("pullreq.lifecycle.create", violations.Addf("lifecycle.create",
"Creation of branch %q is not allowed.", in.RefNames[0]) "Creation of branch %q is not allowed.", in.RefNames[0])
} }
case RefActionDelete: case RefActionDelete:
if v.Lifecycle.DeleteForbidden { if v.Lifecycle.DeleteForbidden {
violations.Addf("pullreq.lifecycle.delete", violations.Addf("lifecycle.delete",
"Delete of branch %q is not allowed.", in.RefNames[0]) "Delete of branch %q is not allowed.", in.RefNames[0])
} }
case RefActionUpdate: case RefActionUpdate:
if v.Lifecycle.UpdateForbidden { if v.Lifecycle.UpdateForbidden {
violations.Addf("pullreq.lifecycle.update", violations.Addf("lifecycle.update",
"Push to branch %q is not allowed. Please use pull requests.", in.RefNames[0]) "Push to branch %q is not allowed. Please use pull requests.", in.RefNames[0])
} }
} }