summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2019-10-21 09:21:45 +0100
committerGitHub <noreply@github.com>2019-10-21 09:21:45 +0100
commit0bfe5eb10b1953cb1f85f7a7b6eb5f24724b8021 (patch)
tree8844040cf40b0f37c9457eade166a8bff1a91152 /models
parentb1c1e1549b50bbd5929e2c4dd72a1dbf4b511b50 (diff)
downloadgitea-0bfe5eb10b1953cb1f85f7a7b6eb5f24724b8021.tar.gz
gitea-0bfe5eb10b1953cb1f85f7a7b6eb5f24724b8021.zip
Allow Protected Branches to Whitelist Deploy Keys (#8483)
Add an option to protected branches to add writing deploy keys to the whitelist for pushing. Please note this is technically a breaking change: previously if the owner of a repository was on the whitelist then any writing deploy key was effectively on the whitelist. This option will now need to be set if that is desired. Closes #8472 Details: * Allow Protected Branches to Whitelist Deploy Keys * Add migration * Ensure that IsDeployKey is set to false on the http pushes * add not null default false
Diffstat (limited to 'models')
-rw-r--r--models/branches.go1
-rw-r--r--models/migrations/migrations.go2
-rw-r--r--models/migrations/v103.go18
-rw-r--r--models/update.go2
4 files changed, 23 insertions, 0 deletions
diff --git a/models/branches.go b/models/branches.go
index fa8beb866c..c5f227f1e5 100644
--- a/models/branches.go
+++ b/models/branches.go
@@ -34,6 +34,7 @@ type ProtectedBranch struct {
WhitelistUserIDs []int64 `xorm:"JSON TEXT"`
WhitelistTeamIDs []int64 `xorm:"JSON TEXT"`
EnableMergeWhitelist bool `xorm:"NOT NULL DEFAULT false"`
+ WhitelistDeployKeys bool `xorm:"NOT NULL DEFAULT false"`
MergeWhitelistUserIDs []int64 `xorm:"JSON TEXT"`
MergeWhitelistTeamIDs []int64 `xorm:"JSON TEXT"`
EnableStatusCheck bool `xorm:"NOT NULL DEFAULT false"`
diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go
index 8064eccfc1..8b1329ea68 100644
--- a/models/migrations/migrations.go
+++ b/models/migrations/migrations.go
@@ -260,6 +260,8 @@ var migrations = []Migration{
NewMigration("change length of some external login users columns", changeSomeColumnsLengthOfExternalLoginUser),
// v102 -> v103
NewMigration("update migration repositories' service type", dropColumnHeadUserNameOnPullRequest),
+ // v103 -> v104
+ NewMigration("Add WhitelistDeployKeys to protected branch", addWhitelistDeployKeysToBranches),
}
// Migrate database to current version
diff --git a/models/migrations/v103.go b/models/migrations/v103.go
new file mode 100644
index 0000000000..fed025c5cd
--- /dev/null
+++ b/models/migrations/v103.go
@@ -0,0 +1,18 @@
+// Copyright 2019 The Gitea Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package migrations
+
+import (
+ "xorm.io/xorm"
+)
+
+func addWhitelistDeployKeysToBranches(x *xorm.Engine) error {
+ type ProtectedBranch struct {
+ ID int64
+ WhitelistDeployKeys bool `xorm:"NOT NULL DEFAULT false"`
+ }
+
+ return x.Sync2(new(ProtectedBranch))
+}
diff --git a/models/update.go b/models/update.go
index c6ea1a845e..5e941c22c4 100644
--- a/models/update.go
+++ b/models/update.go
@@ -22,6 +22,8 @@ const (
EnvPusherName = "GITEA_PUSHER_NAME"
EnvPusherEmail = "GITEA_PUSHER_EMAIL"
EnvPusherID = "GITEA_PUSHER_ID"
+ EnvKeyID = "GITEA_KEY_ID"
+ EnvIsDeployKey = "GITEA_IS_DEPLOY_KEY"
)
// CommitToPushCommit transforms a git.Commit to PushCommit type.