Skip to content

Commit ba8712e

Browse files
Merge pull request #6 from klarna-incubator/master
sync with upstream
2 parents a3915ac + f8a8f18 commit ba8712e

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

sample_repo_configuration.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ wz-pr-restrictions:
106106
approval-quota: 0 # The percentage of individuals reviewing a PR who must approve it before it can be merged
107107
group-quota: 1 # Minimum number of approvals required per group
108108
ignore-self-approve: true # Pull request code contributor approvals are not counted towards quotas
109+
merge-condition: "approvalCount > 1 & groupQuota >= 1"
109110

110111
# Workzone Branch Reviewers
111112
wz-branch-reviewers:

src/bec_wz_pr_restriction_t.erl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
, 'approval-quota' := integer()
1818
, 'group-quota' := integer()
1919
, 'ignore-self-approve' := boolean()
20+
, 'merge-condition' := binary()
2021
}.
2122

2223
%%==============================================================================
@@ -33,25 +34,28 @@ from_map(#{ <<"refName">> := RefName
3334
, <<"approvalQuota">> := ApprovalQuota
3435
, <<"groupQuota">> := GroupQuota
3536
, <<"ignoreContributingReviewersApproval">> := IgnoreSelfApprove
37+
, <<"mergeCondition">> := MergeCondition
3638
}) ->
3739
#{ 'branch-id' => bec_wz_utils:strip_prefix(RefName)
3840
, 'approval-quota' => binary_to_integer(ApprovalQuota)
3941
, 'group-quota' => GroupQuota
4042
, 'ignore-self-approve' => IgnoreSelfApprove
43+
, 'merge-condition' => MergeCondition
4144
}.
4245

4346
-spec to_map(restriction()) -> map().
4447
to_map(#{ 'branch-id' := BranchId
45-
, 'approval-quota' := ApprovalQuota
46-
, 'group-quota' := GroupQuota
4748
} = Map) ->
49+
ApprovalQuota = maps:get('approval-quota', Map, 0),
50+
GroupQuota = maps:get('group-quota', Map, 0),
51+
MergeCondition = maps:get('merge-condition', Map, ""),
4852
IgnoreSelfApprove = maps:get('ignore-self-approve', Map, false),
49-
5053
#{ <<"approvalQuota">> => ApprovalQuota
5154
, <<"approvalQuotaEnabled">> => true
5255
, <<"automergeUsers">> => []
5356
, <<"deleteSourceBranch">> => false
5457
, <<"groupQuota">> => GroupQuota
58+
, <<"mergeCondition">> => MergeCondition
5559
, <<"refName">> => bec_wz_utils:add_prefix(BranchId)
5660
, <<"requiredBuildsCount">> => <<>>
5761
, <<"requiredSignaturesCount">> => <<>>

test/bec_proper_gen.erl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,13 @@ wz_pr_restrictions() ->
175175
unique_list(wz_pr_restriction(), {map, 'branch-id'}).
176176

177177
wz_pr_restriction() ->
178-
?LET( {BranchId, ApprovalQuota, GroupQuota, IgnoreSelfApprove}
179-
, {branch_id(), non_zero_nat(), non_zero_nat(), bool()}
178+
?LET( {BranchId, ApprovalQuota, GroupQuota, IgnoreSelfApprove, MergeCondition}
179+
, {branch_id(), non_zero_nat(), non_zero_nat(), bool(), binary()}
180180
, #{ 'branch-id' => BranchId
181181
, 'approval-quota' => ApprovalQuota
182182
, 'group-quota' => GroupQuota
183183
, 'ignore-self-approve' => IgnoreSelfApprove
184+
, 'merge-condition' => MergeCondition
184185
}).
185186

186187
%%==============================================================================

0 commit comments

Comments
 (0)