mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-17 10:13:37 +02:00
fix build and lint errors
This commit is contained in:
parent
52f6c9bc45
commit
271b6c7cae
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package group
|
package group
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package group
|
package group
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package group
|
package group
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package group
|
package group
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package group
|
package group
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package group
|
package group
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -32,7 +35,7 @@ func GetGroupUnit(ctx context.Context, groupID, teamID int64, unitType unit.Type
|
|||||||
And("team_id = ?", teamID).
|
And("team_id = ?", teamID).
|
||||||
And("type = ?", unitType).
|
And("type = ?", unitType).
|
||||||
Get(unit)
|
Get(unit)
|
||||||
return
|
return unit, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetMaxGroupUnit(ctx context.Context, groupID int64, unitType unit.Type) (unit *RepoGroupUnit, err error) {
|
func GetMaxGroupUnit(ctx context.Context, groupID int64, unitType unit.Type) (unit *RepoGroupUnit, err error) {
|
||||||
@ -42,12 +45,12 @@ func GetMaxGroupUnit(ctx context.Context, groupID int64, unitType unit.Type) (un
|
|||||||
And("type = ?", unitType).
|
And("type = ?", unitType).
|
||||||
Find(&units)
|
Find(&units)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, u := range units {
|
for _, u := range units {
|
||||||
if unit == nil || u.AccessMode > unit.AccessMode {
|
if unit == nil || u.AccessMode > unit.AccessMode {
|
||||||
unit = u
|
unit = u
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return unit, err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package organization
|
package organization
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -1,12 +1,15 @@
|
|||||||
|
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package group
|
package group
|
||||||
|
|
||||||
import (
|
import (
|
||||||
repo_model "code.gitea.io/gitea/models/repo"
|
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"code.gitea.io/gitea/models/db"
|
"code.gitea.io/gitea/models/db"
|
||||||
group_model "code.gitea.io/gitea/models/group"
|
group_model "code.gitea.io/gitea/models/group"
|
||||||
organization_model "code.gitea.io/gitea/models/organization"
|
organization_model "code.gitea.io/gitea/models/organization"
|
||||||
|
repo_model "code.gitea.io/gitea/models/repo"
|
||||||
user_model "code.gitea.io/gitea/models/user"
|
user_model "code.gitea.io/gitea/models/user"
|
||||||
|
|
||||||
"xorm.io/builder"
|
"xorm.io/builder"
|
||||||
|
|||||||
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package structs
|
package structs
|
||||||
|
|
||||||
// Group represents a group of repositories and subgroups in an organization
|
// Group represents a group of repositories and subgroups in an organization
|
||||||
|
|||||||
@ -1,13 +1,16 @@
|
|||||||
|
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package group
|
package group
|
||||||
|
|
||||||
import (
|
import (
|
||||||
access_model "code.gitea.io/gitea/models/perm/access"
|
"errors"
|
||||||
shared_group_model "code.gitea.io/gitea/models/shared/group"
|
|
||||||
"fmt"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
group_model "code.gitea.io/gitea/models/group"
|
group_model "code.gitea.io/gitea/models/group"
|
||||||
|
access_model "code.gitea.io/gitea/models/perm/access"
|
||||||
|
shared_group_model "code.gitea.io/gitea/models/shared/group"
|
||||||
api "code.gitea.io/gitea/modules/structs"
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
"code.gitea.io/gitea/modules/web"
|
"code.gitea.io/gitea/modules/web"
|
||||||
"code.gitea.io/gitea/services/context"
|
"code.gitea.io/gitea/services/context"
|
||||||
@ -18,7 +21,7 @@ import (
|
|||||||
func createCommonGroup(ctx *context.APIContext, parentGroupID, ownerID int64) (*api.Group, error) {
|
func createCommonGroup(ctx *context.APIContext, parentGroupID, ownerID int64) (*api.Group, error) {
|
||||||
if ownerID < 1 {
|
if ownerID < 1 {
|
||||||
if parentGroupID < 1 {
|
if parentGroupID < 1 {
|
||||||
return nil, fmt.Errorf("cannot determine new group's owner")
|
return nil, errors.New("cannot determine new group's owner")
|
||||||
}
|
}
|
||||||
npg, err := group_model.GetGroupByID(ctx, parentGroupID)
|
npg, err := group_model.GetGroupByID(ctx, parentGroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -153,7 +156,10 @@ func MoveGroup(ctx *context.APIContext) {
|
|||||||
npos = *form.NewPos
|
npos = *form.NewPos
|
||||||
}
|
}
|
||||||
err = group_service.MoveGroupItem(ctx, group_service.MoveGroupOptions{
|
err = group_service.MoveGroupItem(ctx, group_service.MoveGroupOptions{
|
||||||
form.NewParent, id, true, npos,
|
NewParent: form.NewParent,
|
||||||
|
ItemID: id,
|
||||||
|
IsGroup: true,
|
||||||
|
NewPos: npos,
|
||||||
}, ctx.Doer)
|
}, ctx.Doer)
|
||||||
if group_model.IsErrGroupNotExist(err) {
|
if group_model.IsErrGroupNotExist(err) {
|
||||||
ctx.APIErrorNotFound()
|
ctx.APIErrorNotFound()
|
||||||
|
|||||||
@ -1304,7 +1304,8 @@ func MoveRepoToGroup(ctx *context.APIContext) {
|
|||||||
npos = *form.NewPos
|
npos = *form.NewPos
|
||||||
}
|
}
|
||||||
err := group_service.MoveGroupItem(ctx, group_service.MoveGroupOptions{
|
err := group_service.MoveGroupItem(ctx, group_service.MoveGroupOptions{
|
||||||
IsGroup: false, NewPos: npos,
|
IsGroup: false,
|
||||||
|
NewPos: npos,
|
||||||
ItemID: ctx.Repo.Repository.ID,
|
ItemID: ctx.Repo.Repository.ID,
|
||||||
NewParent: form.NewParent,
|
NewParent: form.NewParent,
|
||||||
}, ctx.Doer)
|
}, ctx.Doer)
|
||||||
|
|||||||
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package swagger
|
package swagger
|
||||||
|
|
||||||
import api "code.gitea.io/gitea/modules/structs"
|
import api "code.gitea.io/gitea/modules/structs"
|
||||||
|
|||||||
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package convert
|
package convert
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package group
|
package group
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package group
|
package group
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -1,7 +1,11 @@
|
|||||||
|
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package group
|
package group
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -89,7 +93,7 @@ func MoveGroupItem(ctx context.Context, opts MoveGroupOptions, doer *user_model.
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if !canAccessNewParent {
|
if !canAccessNewParent {
|
||||||
return fmt.Errorf("cannot access new parent group")
|
return errors.New("cannot access new parent group")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = parentGroup.LoadSubgroups(ctx, false)
|
err = parentGroup.LoadSubgroups(ctx, false)
|
||||||
|
|||||||
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package group
|
package group
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -42,7 +45,12 @@ func TestMoveGroup(t *testing.T) {
|
|||||||
}
|
}
|
||||||
origCount := unittest.GetCount(t, new(group_model.Group), cond.ToConds())
|
origCount := unittest.GetCount(t, new(group_model.Group), cond.ToConds())
|
||||||
|
|
||||||
assert.NoError(t, MoveGroupItem(t.Context(), MoveGroupOptions{123, gid, true, -1}, doer))
|
assert.NoError(t, MoveGroupItem(t.Context(), MoveGroupOptions{
|
||||||
|
NewParent: 123,
|
||||||
|
ItemID: gid,
|
||||||
|
IsGroup: true,
|
||||||
|
NewPos: -1,
|
||||||
|
}, doer))
|
||||||
unittest.AssertCountByCond(t, "repo_group", cond.ToConds(), origCount+1)
|
unittest.AssertCountByCond(t, "repo_group", cond.ToConds(), origCount+1)
|
||||||
}
|
}
|
||||||
testfn(124)
|
testfn(124)
|
||||||
@ -60,6 +68,11 @@ func TestMoveRepo(t *testing.T) {
|
|||||||
})
|
})
|
||||||
origCount := unittest.GetCount(t, new(repo_model.Repository), cond)
|
origCount := unittest.GetCount(t, new(repo_model.Repository), cond)
|
||||||
|
|
||||||
assert.NoError(t, MoveGroupItem(db.DefaultContext, MoveGroupOptions{123, 32, false, -1}, doer))
|
assert.NoError(t, MoveGroupItem(db.DefaultContext, MoveGroupOptions{
|
||||||
|
NewParent: 123,
|
||||||
|
ItemID: 32,
|
||||||
|
IsGroup: false,
|
||||||
|
NewPos: -1,
|
||||||
|
}, doer))
|
||||||
unittest.AssertCountByCond(t, "repository", cond, origCount+1)
|
unittest.AssertCountByCond(t, "repository", cond, origCount+1)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,15 @@
|
|||||||
|
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package group
|
package group
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"code.gitea.io/gitea/models/perm"
|
|
||||||
"context"
|
"context"
|
||||||
"slices"
|
"slices"
|
||||||
|
|
||||||
"code.gitea.io/gitea/models/git"
|
"code.gitea.io/gitea/models/git"
|
||||||
group_model "code.gitea.io/gitea/models/group"
|
group_model "code.gitea.io/gitea/models/group"
|
||||||
|
"code.gitea.io/gitea/models/perm"
|
||||||
repo_model "code.gitea.io/gitea/models/repo"
|
repo_model "code.gitea.io/gitea/models/repo"
|
||||||
"code.gitea.io/gitea/models/unit"
|
"code.gitea.io/gitea/models/unit"
|
||||||
user_model "code.gitea.io/gitea/models/user"
|
user_model "code.gitea.io/gitea/models/user"
|
||||||
@ -103,7 +106,7 @@ func (w *WebSearchGroup) doLoadChildren(opts *WebSearchOptions) error {
|
|||||||
wsr.LatestCommitStatus = latestCommitStatuses[i]
|
wsr.LatestCommitStatus = latestCommitStatuses[i]
|
||||||
wsr.LocaleLatestCommitStatus = latestCommitStatuses[i].LocaleString(opts.Locale)
|
wsr.LocaleLatestCommitStatus = latestCommitStatuses[i].LocaleString(opts.Locale)
|
||||||
if latestIdx > -1 {
|
if latestIdx > -1 {
|
||||||
if latestCommitStatuses[i].UpdatedUnix.AsLocalTime().Unix() > int64(latestCommitStatuses[latestIdx].UpdatedUnix.AsLocalTime().Unix()) {
|
if latestCommitStatuses[i].UpdatedUnix.AsLocalTime().Unix() > latestCommitStatuses[latestIdx].UpdatedUnix.AsLocalTime().Unix() {
|
||||||
latestIdx = i
|
latestIdx = i
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package group
|
package group
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -68,7 +71,7 @@ func UpdateGroupTeam(ctx context.Context, gt *group_model.RepoGroupTeam) (err er
|
|||||||
And("group_id=?", gt.GroupID).
|
And("group_id=?", gt.GroupID).
|
||||||
And("type = ?", unit.Type).
|
And("type = ?", unit.Type).
|
||||||
Update(unit); err != nil {
|
Update(unit); err != nil {
|
||||||
return
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return committer.Commit()
|
return committer.Commit()
|
||||||
@ -92,7 +95,7 @@ func RecalculateGroupAccess(ctx context.Context, g *group_model.Group, isNew boo
|
|||||||
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.RepoGroupTeam = nil
|
var gt *group_model.RepoGroupTeam
|
||||||
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 err
|
return err
|
||||||
}
|
}
|
||||||
@ -110,7 +113,6 @@ func RecalculateGroupAccess(ctx context.Context, g *group_model.Group, isNew boo
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, u := range t.Units {
|
for _, u := range t.Units {
|
||||||
|
|
||||||
newAccessMode := u.AccessMode
|
newAccessMode := u.AccessMode
|
||||||
if g.ParentGroup == nil {
|
if g.ParentGroup == nil {
|
||||||
gu, err := group_model.GetGroupUnit(ctx, g.ID, t.ID, u.Type)
|
gu, err := group_model.GetGroupUnit(ctx, g.ID, t.ID, u.Type)
|
||||||
|
|||||||
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package group
|
package group
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user