mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-07-10 14:09:20 +02:00
[v11.0/forgejo] fix: corrupted wiki unit default permission (#8234 follow-up) (#8258) (#8445)
Some checks are pending
/ release (push) Waiting to run
testing / test-unit (push) Blocked by required conditions
testing / test-e2e (push) Blocked by required conditions
testing / backend-checks (push) Waiting to run
testing / frontend-checks (push) Waiting to run
testing / test-remote-cacher (redis) (push) Blocked by required conditions
testing / test-remote-cacher (valkey) (push) Blocked by required conditions
testing / test-remote-cacher (garnet) (push) Blocked by required conditions
testing / test-remote-cacher (redict) (push) Blocked by required conditions
testing / test-mysql (push) Blocked by required conditions
testing / test-pgsql (push) Blocked by required conditions
testing / test-sqlite (push) Blocked by required conditions
testing / security-check (push) Blocked by required conditions
Some checks are pending
/ release (push) Waiting to run
testing / test-unit (push) Blocked by required conditions
testing / test-e2e (push) Blocked by required conditions
testing / backend-checks (push) Waiting to run
testing / frontend-checks (push) Waiting to run
testing / test-remote-cacher (redis) (push) Blocked by required conditions
testing / test-remote-cacher (valkey) (push) Blocked by required conditions
testing / test-remote-cacher (garnet) (push) Blocked by required conditions
testing / test-remote-cacher (redict) (push) Blocked by required conditions
testing / test-mysql (push) Blocked by required conditions
testing / test-pgsql (push) Blocked by required conditions
testing / test-sqlite (push) Blocked by required conditions
testing / security-check (push) Blocked by required conditions
**Backport of** https://codeberg.org/forgejo/forgejo/pulls/8258, cherry picked from commitcee2aae4ca
Manual adjustments: - rename the migration file from `v36` to `v29` - added the `//nolint:revive` --- Closes #8119, follow-up of #8234 (**backported in #8237**) ## Testing - go to a commit before #8234 (e.g.285f66b782
) - create 3 repositories - save the wiki settings of the second, without any change - set the wiki of the third to be globally writable - verify the `default_permissions` column in the database, of the unit `5`: 0, 2, 3 - stop Forgejo, switch to this PR and start Forgejo - verify that the logs writes `Migration[35]: Fix wiki unit default permission` - verify the `default_permissions` column in the database, of the unit `5`: 0, 0, 3 Before:  After:  - [x] I did not document these changes and I do not expect someone else to do it. - [x] I do not want this change to show in the release notes. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8445 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Co-authored-by: oliverpool <git@olivier.pfad.fr> Co-committed-by: oliverpool <git@olivier.pfad.fr>
This commit is contained in:
parent
86b6553f3a
commit
094eb89b5e
3 changed files with 13 additions and 10 deletions
|
@ -41,27 +41,30 @@ func (err ErrUnitTypeNotExist) Unwrap() error {
|
|||
}
|
||||
|
||||
// RepoUnitAccessMode specifies the users access mode to a repo unit
|
||||
// Only UnitAccessModeWrite is used by the wiki, to mark it as instance-writable
|
||||
type UnitAccessMode int
|
||||
|
||||
const (
|
||||
// UnitAccessModeUnset - no unit mode set
|
||||
UnitAccessModeUnset UnitAccessMode = iota // 0
|
||||
|
||||
// UnitAccessModeNone no access
|
||||
UnitAccessModeNone // 1
|
||||
// UnitAccessModeNone UnitAccessMode = 1
|
||||
// UnitAccessModeRead read access
|
||||
UnitAccessModeRead // 2
|
||||
// UnitAccessModeRead UnitAccessMode = 2
|
||||
|
||||
// UnitAccessModeWrite write access
|
||||
UnitAccessModeWrite // 3
|
||||
UnitAccessModeWrite UnitAccessMode = 3
|
||||
)
|
||||
|
||||
func (mode UnitAccessMode) ToAccessMode(modeIfUnset perm.AccessMode) perm.AccessMode {
|
||||
switch mode {
|
||||
case UnitAccessModeUnset:
|
||||
return modeIfUnset
|
||||
case UnitAccessModeNone:
|
||||
return perm.AccessModeNone
|
||||
case UnitAccessModeRead:
|
||||
return perm.AccessModeRead
|
||||
// case UnitAccessModeNone:
|
||||
// return perm.AccessModeNone
|
||||
// case UnitAccessModeRead:
|
||||
// return perm.AccessModeRead
|
||||
case UnitAccessModeWrite:
|
||||
return perm.AccessModeWrite
|
||||
default:
|
||||
|
|
|
@ -34,8 +34,8 @@ func TestActionsConfig(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRepoUnitAccessMode(t *testing.T) {
|
||||
assert.Equal(t, perm.AccessModeNone, UnitAccessModeNone.ToAccessMode(perm.AccessModeAdmin))
|
||||
assert.Equal(t, perm.AccessModeRead, UnitAccessModeRead.ToAccessMode(perm.AccessModeAdmin))
|
||||
// assert.Equal(t, perm.AccessModeNone, UnitAccessModeNone.ToAccessMode(perm.AccessModeAdmin))
|
||||
// assert.Equal(t, perm.AccessModeRead, UnitAccessModeRead.ToAccessMode(perm.AccessModeAdmin))
|
||||
assert.Equal(t, perm.AccessModeWrite, UnitAccessModeWrite.ToAccessMode(perm.AccessModeAdmin))
|
||||
assert.Equal(t, perm.AccessModeRead, UnitAccessModeUnset.ToAccessMode(perm.AccessModeRead))
|
||||
}
|
||||
|
|
|
@ -861,7 +861,7 @@ func updateRepoUnits(ctx *context.APIContext, owner string, repo *repo_model.Rep
|
|||
if *opts.GloballyEditableWiki {
|
||||
wikiPermissions = repo_model.UnitAccessModeWrite
|
||||
} else {
|
||||
wikiPermissions = repo_model.UnitAccessModeRead
|
||||
wikiPermissions = repo_model.UnitAccessModeUnset
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue