Skip to content

WIP: Use intermediate table to compute user permissions #9787

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
3f5ba64
Add user_repo_unit
guillep2k Jan 12, 2020
376ee94
Move tests a little
guillep2k Jan 15, 2020
a223c12
Fix test
guillep2k Jan 15, 2020
c86e6c9
Fix fmt
guillep2k Jan 15, 2020
51a9ba5
Fix comments
guillep2k Jan 15, 2020
c8f09af
Fix lint
guillep2k Jan 16, 2020
920b510
Fix comment & fixture
guillep2k Jan 16, 2020
61893b1
Merge branch 'master' into user-repo-unit
guillep2k Jan 16, 2020
da2f517
Fix lint
guillep2k Jan 16, 2020
32aadd3
Re-arrange some delete operations
guillep2k Jan 16, 2020
bf70396
Add UnitTypeReleases by @davidsvantesson
guillep2k Jan 17, 2020
431d70c
First steps for using the new system
guillep2k Jan 19, 2020
bdc5d20
Add fixtures, passes unit tests
guillep2k Jan 19, 2020
6b310b6
Pass test-sqlite-migration
guillep2k Jan 19, 2020
ac0fe2f
Add missing tables to models.go
guillep2k Jan 19, 2020
8a028db
Added uru yaml generation
guillep2k Jan 19, 2020
7c1f23a
Add locked resources
guillep2k Jan 19, 2020
b3fa987
Merge branch 'master' into user-repo-unit
guillep2k Jan 29, 2020
49a8f5b
tmpwork
guillep2k Jan 29, 2020
03c715c
xxxx
guillep2k Jan 30, 2020
ecd4ddb
GetRepositoryAccesses() - no pasa el test
guillep2k Jan 30, 2020
2a19edf
Remove batchID from tables, update comments
guillep2k Feb 7, 2020
fe0c17b
Move to temporary work table
guillep2k Feb 8, 2020
acb4172
Neater error vars
guillep2k Feb 9, 2020
95b0112
Fix fixture to new uru method
guillep2k Feb 12, 2020
a9c0738
Más fixes
guillep2k Feb 12, 2020
75e0b72
Fix uruyaml test
guillep2k Feb 13, 2020
26fefe1
Changes from #10247 for test consistency
guillep2k Feb 13, 2020
3872d69
Pass TestUser_GetAccessibleRepositories
guillep2k Feb 13, 2020
b124a48
Add TestUserRepoUnit_Repo5
guillep2k Feb 13, 2020
eaf90f8
Add missing repo_unit for repo id: 5
guillep2k Feb 13, 2020
525db6a
Update user_repo_unit.yml
guillep2k Feb 13, 2020
5f98b2c
Fix access test to match master
guillep2k Feb 13, 2020
351e0d2
Fix GetRepositoryAccesses to use only explicit
guillep2k Feb 13, 2020
dc8ef08
Improve comment
guillep2k Feb 13, 2020
5a8474d
Merge branch 'master' into user-repo-unit
guillep2k Feb 15, 2020
c7a9c56
Add user_repo_unit to yaml generation
guillep2k Feb 15, 2020
e94284c
Remove 'access' from yaml generation
guillep2k Feb 15, 2020
5949c93
Remove old user_repo_unit generation
guillep2k Feb 15, 2020
3bcfbc5
Remove accidental .swp
guillep2k May 19, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions integrations/user_repo_unit_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2020 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 integrations

import (
"testing"

"code.gitea.io/gitea/models"
)

// IMPORTANT: THIS FILE IS ONLY A BUILDING BLOCK TO HELP TEST THE FEATURE
// DURING DEVELOPMENT. IT'S NOT INTENDED TO GO LIKE THIS IN THE FINAL
// VERSION OF THE PR.

func TestUserRepoUnit(t *testing.T) {

models.UserRepoUnitTest(t)
}
1 change: 1 addition & 0 deletions models/fixtures/repository.yml
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@
owner_name: user2
lower_name: repo20
name: repo20
is_private: true
num_stars: 0
num_forks: 0
num_issues: 0
Expand Down
10 changes: 10 additions & 0 deletions models/migrations/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,16 @@ Please try to upgrade to a lower version (>= v0.6.0) first, then upgrade to curr
return err
}
}

// IMPORTANT: THIS MIGRATION DOES NOT HAVE IT'S FINAL NUMBER OR FORM.
// IT'S NOT INTENDED TO GO LIKE THIS IN THE FINAL VERSION OF THE PR.
// FIXME: GAP: assign a proper migration number and remove from here
// NewMigration("Add and populate the user_repo_unit table", addUserRepoUnit),
log.Info("FIXME: GAP: Migration[999/%d]: Add and populate the user_repo_unit table", currentVersion.Version)
if err = addUserRepoUnit(x); err != nil {
return fmt.Errorf("do migrate: %v", err)
}

return nil
}

Expand Down
40 changes: 40 additions & 0 deletions models/migrations/v999.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright 2020 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"
)

// IMPORTANT: THIS MIGRATION DOES NOT HAVE IT'S FINAL NUMBER OR FORM.
// IT'S NOT INTENDED TO GO LIKE THIS IN THE FINAL VERSION OF THE PR.

func addUserRepoUnit(x *xorm.Engine) error {

// AccessMode is Unit's Type
type AccessMode int
type UnitType int

type UserRepoUnit struct {
UserID int64 `xorm:"pk"`
RepoID int64 `xorm:"pk INDEX"`
Type UnitType `xorm:"pk"`
Mode AccessMode `xorm:"NOT NULL"`
}

type UserRepoUnitWork struct {
BatchID int64 `xorm:"NOT NULL INDEX"`
UserID int64 `xorm:"NOT NULL"`
RepoID int64 `xorm:"NOT NULL"`
Type UnitType `xorm:"NOT NULL"`
Mode AccessMode `xorm:"NOT NULL"`
}

type UserRepoUnitBatchNumber struct {
ID int64 `xorm:"pk autoincr"`
}

return x.Sync2(new(UserRepoUnit), new(UserRepoUnitWork), new(UserRepoUnitBatchNumber))
}
Loading