mirror of
https://github.com/go-gitea/gitea
synced 2025-12-07 13:28:25 +00:00
rename IsAllRepositories to IncludesAllRepositories
This commit is contained in:
@@ -224,7 +224,7 @@ var migrations = []Migration{
|
||||
// v84 -> v85
|
||||
NewMigration("add table to store original imported gpg keys", addGPGKeyImport),
|
||||
// v85 -> v86
|
||||
NewMigration("add is_all_repositories to teams", addTeamIsAllRepositories),
|
||||
NewMigration("add includes_all_repositories to teams", addTeamIncludesAllRepositories),
|
||||
}
|
||||
|
||||
// Migrate database to current version
|
||||
|
||||
@@ -8,18 +8,18 @@ import (
|
||||
"github.com/go-xorm/xorm"
|
||||
)
|
||||
|
||||
func addTeamIsAllRepositories(x *xorm.Engine) error {
|
||||
func addTeamIncludesAllRepositories(x *xorm.Engine) error {
|
||||
|
||||
type Team struct {
|
||||
ID int64 `xorm:"pk autoincr"`
|
||||
IsAllRepositories bool `xorm:"NOT NULL DEFAULT false"`
|
||||
ID int64 `xorm:"pk autoincr"`
|
||||
IncludesAllRepositories bool `xorm:"NOT NULL DEFAULT false"`
|
||||
}
|
||||
|
||||
if err := x.Sync2(new(Team)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err := x.Exec("UPDATE `team` SET `is_all_repositories` = ? WHERE `name`=?",
|
||||
_, err := x.Exec("UPDATE `team` SET `includes_all_repositories` = ? WHERE `name`=?",
|
||||
true, "Owners")
|
||||
return err
|
||||
}
|
||||
|
||||
+6
-6
@@ -152,12 +152,12 @@ func CreateOrganization(org, owner *User) (err error) {
|
||||
|
||||
// Create default owner team.
|
||||
t := &Team{
|
||||
OrgID: org.ID,
|
||||
LowerName: strings.ToLower(ownerTeamName),
|
||||
Name: ownerTeamName,
|
||||
Authorize: AccessModeOwner,
|
||||
NumMembers: 1,
|
||||
IsAllRepositories: true,
|
||||
OrgID: org.ID,
|
||||
LowerName: strings.ToLower(ownerTeamName),
|
||||
Name: ownerTeamName,
|
||||
Authorize: AccessModeOwner,
|
||||
NumMembers: 1,
|
||||
IncludesAllRepositories: true,
|
||||
}
|
||||
if _, err = sess.Insert(t); err != nil {
|
||||
return fmt.Errorf("insert owner team: %v", err)
|
||||
|
||||
+15
-15
@@ -21,18 +21,18 @@ const ownerTeamName = "Owners"
|
||||
|
||||
// Team represents a organization team.
|
||||
type Team struct {
|
||||
ID int64 `xorm:"pk autoincr"`
|
||||
OrgID int64 `xorm:"INDEX"`
|
||||
LowerName string
|
||||
Name string
|
||||
Description string
|
||||
Authorize AccessMode
|
||||
Repos []*Repository `xorm:"-"`
|
||||
Members []*User `xorm:"-"`
|
||||
NumRepos int
|
||||
NumMembers int
|
||||
Units []*TeamUnit `xorm:"-"`
|
||||
IsAllRepositories bool `xorm:"NOT NULL DEFAULT false"`
|
||||
ID int64 `xorm:"pk autoincr"`
|
||||
OrgID int64 `xorm:"INDEX"`
|
||||
LowerName string
|
||||
Name string
|
||||
Description string
|
||||
Authorize AccessMode
|
||||
Repos []*Repository `xorm:"-"`
|
||||
Members []*User `xorm:"-"`
|
||||
NumRepos int
|
||||
NumMembers int
|
||||
Units []*TeamUnit `xorm:"-"`
|
||||
IncludesAllRepositories bool `xorm:"NOT NULL DEFAULT false"`
|
||||
}
|
||||
|
||||
// ColorFormat provides a basic color format for a Team
|
||||
@@ -247,7 +247,7 @@ func (t *Team) RemoveRepository(repoID int64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
if t.IsAllRepositories {
|
||||
if t.IncludesAllRepositories {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -349,7 +349,7 @@ func NewTeam(t *Team) (err error) {
|
||||
}
|
||||
|
||||
// Add all repositories to the team if it has access to all of them.
|
||||
if t.IsAllRepositories {
|
||||
if t.IncludesAllRepositories {
|
||||
err = t.addAllRepositories(sess)
|
||||
if err != nil {
|
||||
return fmt.Errorf("addAllRepositories: %v", err)
|
||||
@@ -463,7 +463,7 @@ func UpdateTeam(t *Team, authChanged bool) (err error) {
|
||||
}
|
||||
|
||||
// Add all repositories to the team if it has access to all of them.
|
||||
if t.IsAllRepositories {
|
||||
if t.IncludesAllRepositories {
|
||||
err = t.addAllRepositories(sess)
|
||||
if err != nil {
|
||||
return fmt.Errorf("addAllRepositories: %v", err)
|
||||
|
||||
+19
-19
@@ -397,7 +397,7 @@ func TestAllRepositoriesTeams(t *testing.T) {
|
||||
// Check Owner team.
|
||||
ownerTeam, err := org.GetOwnerTeam()
|
||||
assert.NoError(t, err, "GetOwnerTeam")
|
||||
assert.True(t, ownerTeam.IsAllRepositories, "Owner team is all repositories")
|
||||
assert.True(t, ownerTeam.IncludesAllRepositories, "Owner team includes all repositories")
|
||||
|
||||
// Create repos.
|
||||
repoIds := make([]int64, 0)
|
||||
@@ -413,28 +413,28 @@ func TestAllRepositoriesTeams(t *testing.T) {
|
||||
teams := []*Team{
|
||||
ownerTeam,
|
||||
{
|
||||
OrgID: org.ID,
|
||||
Name: "team one",
|
||||
Authorize: AccessModeRead,
|
||||
IsAllRepositories: true,
|
||||
OrgID: org.ID,
|
||||
Name: "team one",
|
||||
Authorize: AccessModeRead,
|
||||
IncludesAllRepositories: true,
|
||||
},
|
||||
{
|
||||
OrgID: org.ID,
|
||||
Name: "team 2",
|
||||
Authorize: AccessModeRead,
|
||||
IsAllRepositories: false,
|
||||
OrgID: org.ID,
|
||||
Name: "team 2",
|
||||
Authorize: AccessModeRead,
|
||||
IncludesAllRepositories: false,
|
||||
},
|
||||
{
|
||||
OrgID: org.ID,
|
||||
Name: "team three",
|
||||
Authorize: AccessModeWrite,
|
||||
IsAllRepositories: true,
|
||||
OrgID: org.ID,
|
||||
Name: "team three",
|
||||
Authorize: AccessModeWrite,
|
||||
IncludesAllRepositories: true,
|
||||
},
|
||||
{
|
||||
OrgID: org.ID,
|
||||
Name: "team 4",
|
||||
Authorize: AccessModeWrite,
|
||||
IsAllRepositories: false,
|
||||
OrgID: org.ID,
|
||||
Name: "team 4",
|
||||
Authorize: AccessModeWrite,
|
||||
IncludesAllRepositories: false,
|
||||
},
|
||||
}
|
||||
repoCounts := []int{3, 3, 0, 3, 0}
|
||||
@@ -447,8 +447,8 @@ func TestAllRepositoriesTeams(t *testing.T) {
|
||||
}
|
||||
|
||||
// Update teams and check repo count.
|
||||
teams[3].IsAllRepositories = false
|
||||
teams[4].IsAllRepositories = true
|
||||
teams[3].IncludesAllRepositories = false
|
||||
teams[4].IncludesAllRepositories = true
|
||||
repoCounts[4] = 3
|
||||
for i, team := range teams {
|
||||
assert.NoError(t, UpdateTeam(team, false), "team %d: UpdateTeam", i)
|
||||
|
||||
+1
-1
@@ -1361,7 +1361,7 @@ func createRepository(e *xorm.Session, doer, u *User, repo *Repository) (err err
|
||||
return fmt.Errorf("GetTeams: %v", err)
|
||||
}
|
||||
for _, t := range u.Teams {
|
||||
if t.IsAllRepositories {
|
||||
if t.IncludesAllRepositories {
|
||||
if err := t.addRepository(e, repo); err != nil {
|
||||
return fmt.Errorf("addRepository: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user