tenseleyflow/shithub / c7d158f

Browse files

repos/branch_protection: thread require_signed_commits through upsert+update

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
c7d158f73150945fa011a4aca65bb71f17b74d06
Parents
8d95c1f
Tree
b3b8bbc

2 changed files

StatusFile+-
M internal/repos/queries/branch_protection.sql 3 1
M internal/repos/sqlc/branch_protection.sql.go 7 1
internal/repos/queries/branch_protection.sqlmodified
@@ -27,9 +27,10 @@ WHERE id = $1;
2727
 INSERT INTO branch_protection_rules (
2828
     repo_id, pattern,
2929
     prevent_force_push, prevent_deletion, require_pr_for_push,
30
+    require_signed_commits,
3031
     allowed_pusher_user_ids, created_by_user_id
3132
 ) VALUES (
32
-    $1, $2, $3, $4, $5, $6, sqlc.narg(created_by_user_id)::bigint
33
+    $1, $2, $3, $4, $5, sqlc.arg(require_signed_commits)::boolean, $6, sqlc.narg(created_by_user_id)::bigint
3334
 )
3435
 RETURNING id;
3536
 
@@ -39,6 +40,7 @@ SET pattern = $2,
3940
     prevent_force_push = $3,
4041
     prevent_deletion = $4,
4142
     require_pr_for_push = $5,
43
+    require_signed_commits = sqlc.arg(require_signed_commits)::boolean,
4244
     allowed_pusher_user_ids = $6
4345
 WHERE id = $1;
4446
 
internal/repos/sqlc/branch_protection.sql.gomodified
@@ -161,6 +161,7 @@ SET pattern = $2,
161161
     prevent_force_push = $3,
162162
     prevent_deletion = $4,
163163
     require_pr_for_push = $5,
164
+    require_signed_commits = $7::boolean,
164165
     allowed_pusher_user_ids = $6
165166
 WHERE id = $1
166167
 `
@@ -172,6 +173,7 @@ type UpdateBranchProtectionRuleParams struct {
172173
 	PreventDeletion      bool
173174
 	RequirePrForPush     bool
174175
 	AllowedPusherUserIds []int64
176
+	RequireSignedCommits bool
175177
 }
176178
 
177179
 func (q *Queries) UpdateBranchProtectionRule(ctx context.Context, db DBTX, arg UpdateBranchProtectionRuleParams) error {
@@ -182,6 +184,7 @@ func (q *Queries) UpdateBranchProtectionRule(ctx context.Context, db DBTX, arg U
182184
 		arg.PreventDeletion,
183185
 		arg.RequirePrForPush,
184186
 		arg.AllowedPusherUserIds,
187
+		arg.RequireSignedCommits,
185188
 	)
186189
 	return err
187190
 }
@@ -206,9 +209,10 @@ const upsertBranchProtectionRule = `-- name: UpsertBranchProtectionRule :one
206209
 INSERT INTO branch_protection_rules (
207210
     repo_id, pattern,
208211
     prevent_force_push, prevent_deletion, require_pr_for_push,
212
+    require_signed_commits,
209213
     allowed_pusher_user_ids, created_by_user_id
210214
 ) VALUES (
211
-    $1, $2, $3, $4, $5, $6, $7::bigint
215
+    $1, $2, $3, $4, $5, $7::boolean, $6, $8::bigint
212216
 )
213217
 RETURNING id
214218
 `
@@ -220,6 +224,7 @@ type UpsertBranchProtectionRuleParams struct {
220224
 	PreventDeletion      bool
221225
 	RequirePrForPush     bool
222226
 	AllowedPusherUserIds []int64
227
+	RequireSignedCommits bool
223228
 	CreatedByUserID      pgtype.Int8
224229
 }
225230
 
@@ -231,6 +236,7 @@ func (q *Queries) UpsertBranchProtectionRule(ctx context.Context, db DBTX, arg U
231236
 		arg.PreventDeletion,
232237
 		arg.RequirePrForPush,
233238
 		arg.AllowedPusherUserIds,
239
+		arg.RequireSignedCommits,
234240
 		arg.CreatedByUserID,
235241
 	)
236242
 	var id int64