mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-12 04:43:32 +02:00
apply simple linting changes
This commit is contained in:
parent
47531417e9
commit
f627e57199
@ -2,6 +2,7 @@ package group
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"code.gitea.io/gitea/models/db"
|
"code.gitea.io/gitea/models/db"
|
||||||
@ -13,7 +14,8 @@ import (
|
|||||||
"code.gitea.io/gitea/modules/util"
|
"code.gitea.io/gitea/modules/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewGroup(ctx context.Context, g *group_model.Group) (err error) {
|
func NewGroup(ctx context.Context, g *group_model.Group) error {
|
||||||
|
var err error
|
||||||
if len(g.Name) == 0 {
|
if len(g.Name) == 0 {
|
||||||
return util.NewInvalidArgumentErrorf("empty group name")
|
return util.NewInvalidArgumentErrorf("empty group name")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -79,38 +79,38 @@ func UpdateGroupTeam(ctx context.Context, gt *group_model.GroupTeam) (err error)
|
|||||||
|
|
||||||
// RecalculateGroupAccess recalculates team access to a group.
|
// RecalculateGroupAccess recalculates team access to a group.
|
||||||
// should only be called if and only if a group was moved from another group.
|
// should only be called if and only if a group was moved from another group.
|
||||||
func RecalculateGroupAccess(ctx context.Context, g *group_model.Group, isNew bool) (err error) {
|
func RecalculateGroupAccess(ctx context.Context, g *group_model.Group, isNew bool) error {
|
||||||
|
var err error
|
||||||
sess := db.GetEngine(ctx)
|
sess := db.GetEngine(ctx)
|
||||||
if err = g.LoadParentGroup(ctx); err != nil {
|
if err = g.LoadParentGroup(ctx); err != nil {
|
||||||
return
|
return err
|
||||||
}
|
}
|
||||||
var teams []*org_model.Team
|
var teams []*org_model.Team
|
||||||
if g.ParentGroup == nil {
|
if g.ParentGroup == nil {
|
||||||
teams, err = org_model.FindOrgTeams(ctx, g.OwnerID)
|
teams, err = org_model.FindOrgTeams(ctx, g.OwnerID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
teams, err = org_model.GetTeamsWithAccessToGroup(ctx, g.OwnerID, g.ParentGroupID, perm.AccessModeRead)
|
teams, err = org_model.GetTeamsWithAccessToGroup(ctx, g.OwnerID, g.ParentGroupID, perm.AccessModeRead)
|
||||||
}
|
}
|
||||||
for _, t := range teams {
|
for _, t := range teams {
|
||||||
|
|
||||||
var gt *group_model.GroupTeam = nil
|
var gt *group_model.GroupTeam = nil
|
||||||
if gt, err = group_model.FindGroupTeamByTeamID(ctx, g.ParentGroupID, t.ID); err != nil {
|
if gt, err = group_model.FindGroupTeamByTeamID(ctx, g.ParentGroupID, t.ID); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if gt != nil {
|
if gt != nil {
|
||||||
if err = group_model.UpdateTeamGroup(ctx, g.OwnerID, t.ID, g.ID, gt.AccessMode, gt.CanCreateIn, isNew); err != nil {
|
if err = group_model.UpdateTeamGroup(ctx, g.OwnerID, t.ID, g.ID, gt.AccessMode, gt.CanCreateIn, isNew); err != nil {
|
||||||
return
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if err = group_model.UpdateTeamGroup(ctx, g.OwnerID, t.ID, g.ID, t.AccessMode, t.IsOwnerTeam() || t.AccessMode >= perm.AccessModeAdmin || t.CanCreateOrgRepo, isNew); err != nil {
|
if err = group_model.UpdateTeamGroup(ctx, g.OwnerID, t.ID, g.ID, t.AccessMode, t.IsOwnerTeam() || t.AccessMode >= perm.AccessModeAdmin || t.CanCreateOrgRepo, isNew); err != nil {
|
||||||
return
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = t.LoadUnits(ctx); err != nil {
|
if err = t.LoadUnits(ctx); err != nil {
|
||||||
return
|
return err
|
||||||
}
|
}
|
||||||
for _, u := range t.Units {
|
for _, u := range t.Units {
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ func RecalculateGroupAccess(ctx context.Context, g *group_model.Group, isNew boo
|
|||||||
GroupID: g.ID,
|
GroupID: g.ID,
|
||||||
AccessMode: newAccessMode,
|
AccessMode: newAccessMode,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if _, err = sess.Table("group_unit").Where(builder.Eq{
|
if _, err = sess.Table("group_unit").Where(builder.Eq{
|
||||||
@ -144,5 +144,5 @@ func RecalculateGroupAccess(ctx context.Context, g *group_model.Group, isNew boo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user