mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-20 20:07:03 +01:00
migration v1_11/v111.go: Unknown columns in 'field list'
This commit is contained in:
parent
639ac7a131
commit
25daa267bb
1 changed files with 13 additions and 12 deletions
|
@ -23,9 +23,9 @@ func AddBranchProtectionCanPushAndEnableWhitelist(x *xorm.Engine) error {
|
||||||
Type int
|
Type int
|
||||||
|
|
||||||
// Permissions
|
// Permissions
|
||||||
IsAdmin bool
|
IsAdmin bool
|
||||||
IsRestricted bool `xorm:"NOT NULL DEFAULT false"`
|
// IsRestricted bool `xorm:"NOT NULL DEFAULT false"` glitch: this column was added in v1_12/v121.go
|
||||||
Visibility int `xorm:"NOT NULL DEFAULT 0"`
|
// Visibility int `xorm:"NOT NULL DEFAULT 0"` glitch: this column was added in v1_12/v124.go
|
||||||
}
|
}
|
||||||
|
|
||||||
type Review struct {
|
type Review struct {
|
||||||
|
@ -51,9 +51,9 @@ func AddBranchProtectionCanPushAndEnableWhitelist(x *xorm.Engine) error {
|
||||||
ReviewTypeReject int = 3
|
ReviewTypeReject int = 3
|
||||||
|
|
||||||
// VisibleTypePublic Visible for everyone
|
// VisibleTypePublic Visible for everyone
|
||||||
VisibleTypePublic int = 0
|
// VisibleTypePublic int = 0
|
||||||
// VisibleTypePrivate Visible only for organization's members
|
// VisibleTypePrivate Visible only for organization's members
|
||||||
VisibleTypePrivate int = 2
|
// VisibleTypePrivate int = 2
|
||||||
|
|
||||||
// unit.UnitTypeCode is unit type code
|
// unit.UnitTypeCode is unit type code
|
||||||
UnitTypeCode int = 1
|
UnitTypeCode int = 1
|
||||||
|
@ -145,9 +145,9 @@ func AddBranchProtectionCanPushAndEnableWhitelist(x *xorm.Engine) error {
|
||||||
hasOrgVisible := true
|
hasOrgVisible := true
|
||||||
// Not SignedUser
|
// Not SignedUser
|
||||||
if user == nil {
|
if user == nil {
|
||||||
hasOrgVisible = repoOwner.Visibility == VisibleTypePublic
|
// hasOrgVisible = repoOwner.Visibility == VisibleTypePublic // VisibleTypePublic is the default
|
||||||
} else if !user.IsAdmin {
|
} else if !user.IsAdmin {
|
||||||
hasMemberWithUserID, err := sess.
|
_, err := sess.
|
||||||
Where("uid=?", user.ID).
|
Where("uid=?", user.ID).
|
||||||
And("org_id=?", repoOwner.ID).
|
And("org_id=?", repoOwner.ID).
|
||||||
Table("org_user").
|
Table("org_user").
|
||||||
|
@ -155,9 +155,10 @@ func AddBranchProtectionCanPushAndEnableWhitelist(x *xorm.Engine) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
hasOrgVisible = false
|
hasOrgVisible = false
|
||||||
}
|
}
|
||||||
if (repoOwner.Visibility == VisibleTypePrivate || user.IsRestricted) && !hasMemberWithUserID {
|
// VisibleTypePublic is the default so the condition below is always false
|
||||||
hasOrgVisible = false
|
// if (repoOwner.Visibility == VisibleTypePrivate) && !hasMemberWithUserID {
|
||||||
}
|
// hasOrgVisible = false
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
isCollaborator, err := sess.Get(&Collaboration{RepoID: repo.ID, UserID: user.ID})
|
isCollaborator, err := sess.Get(&Collaboration{RepoID: repo.ID, UserID: user.ID})
|
||||||
|
@ -195,7 +196,7 @@ func AddBranchProtectionCanPushAndEnableWhitelist(x *xorm.Engine) error {
|
||||||
|
|
||||||
if user != nil {
|
if user != nil {
|
||||||
userID = user.ID
|
userID = user.ID
|
||||||
restricted = user.IsRestricted
|
restricted = false
|
||||||
}
|
}
|
||||||
|
|
||||||
if !restricted && !repo.IsPrivate {
|
if !restricted && !repo.IsPrivate {
|
||||||
|
@ -284,7 +285,7 @@ func AddBranchProtectionCanPushAndEnableWhitelist(x *xorm.Engine) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// for a public repo on an organization, a non-restricted user has read permission on non-team defined units.
|
// for a public repo on an organization, a non-restricted user has read permission on non-team defined units.
|
||||||
if !found && !repo.IsPrivate && !user.IsRestricted {
|
if !found && !repo.IsPrivate {
|
||||||
if _, ok := perm.UnitsMode[u.Type]; !ok {
|
if _, ok := perm.UnitsMode[u.Type]; !ok {
|
||||||
perm.UnitsMode[u.Type] = AccessModeRead
|
perm.UnitsMode[u.Type] = AccessModeRead
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue