0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-04-03 21:12:09 +02:00

fix build and lint errors

This commit is contained in:
☙◦ The Tablet ❀ GamerGirlandCo ◦❧ 2025-08-14 18:01:52 -04:00
parent 52f6c9bc45
commit 271b6c7cae
No known key found for this signature in database
GPG Key ID: 924A5F6AF051E87C
20 changed files with 89 additions and 18 deletions

View File

@ -1,3 +1,6 @@
// Copyright 2025 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package group
import (

View File

@ -1,3 +1,6 @@
// Copyright 2025 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package group
import (

View File

@ -1,3 +1,6 @@
// Copyright 2025 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package group
import (

View File

@ -1,3 +1,6 @@
// Copyright 2025 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package group
import (

View File

@ -1,3 +1,6 @@
// Copyright 2025 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package group
import (

View File

@ -1,3 +1,6 @@
// Copyright 2025 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package group
import (
@ -32,7 +35,7 @@ func GetGroupUnit(ctx context.Context, groupID, teamID int64, unitType unit.Type
And("team_id = ?", teamID).
And("type = ?", unitType).
Get(unit)
return
return unit, err
}
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).
Find(&units)
if err != nil {
return
return nil, err
}
for _, u := range units {
if unit == nil || u.AccessMode > unit.AccessMode {
unit = u
}
}
return
return unit, err
}

View File

@ -1,3 +1,6 @@
// Copyright 2025 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package organization
import (

View File

@ -1,12 +1,15 @@
// Copyright 2025 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package group
import (
repo_model "code.gitea.io/gitea/models/repo"
"context"
"code.gitea.io/gitea/models/db"
group_model "code.gitea.io/gitea/models/group"
organization_model "code.gitea.io/gitea/models/organization"
repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
"xorm.io/builder"

View File

@ -1,3 +1,6 @@
// Copyright 2025 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package structs
// Group represents a group of repositories and subgroups in an organization

View File

@ -1,13 +1,16 @@
// Copyright 2025 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package group
import (
access_model "code.gitea.io/gitea/models/perm/access"
shared_group_model "code.gitea.io/gitea/models/shared/group"
"fmt"
"errors"
"net/http"
"strings"
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"
"code.gitea.io/gitea/modules/web"
"code.gitea.io/gitea/services/context"
@ -18,7 +21,7 @@ import (
func createCommonGroup(ctx *context.APIContext, parentGroupID, ownerID int64) (*api.Group, error) {
if ownerID < 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)
if err != nil {
@ -153,7 +156,10 @@ func MoveGroup(ctx *context.APIContext) {
npos = *form.NewPos
}
err = group_service.MoveGroupItem(ctx, group_service.MoveGroupOptions{
form.NewParent, id, true, npos,
NewParent: form.NewParent,
ItemID: id,
IsGroup: true,
NewPos: npos,
}, ctx.Doer)
if group_model.IsErrGroupNotExist(err) {
ctx.APIErrorNotFound()

View File

@ -1304,7 +1304,8 @@ func MoveRepoToGroup(ctx *context.APIContext) {
npos = *form.NewPos
}
err := group_service.MoveGroupItem(ctx, group_service.MoveGroupOptions{
IsGroup: false, NewPos: npos,
IsGroup: false,
NewPos: npos,
ItemID: ctx.Repo.Repository.ID,
NewParent: form.NewParent,
}, ctx.Doer)

View File

@ -1,3 +1,6 @@
// Copyright 2025 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package swagger
import api "code.gitea.io/gitea/modules/structs"

View File

@ -1,3 +1,6 @@
// Copyright 2025 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package convert
import (

View File

@ -1,3 +1,6 @@
// Copyright 2025 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package group
import (

View File

@ -1,3 +1,6 @@
// Copyright 2025 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package group
import (

View File

@ -1,7 +1,11 @@
// Copyright 2025 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package group
import (
"context"
"errors"
"fmt"
"strings"
@ -89,7 +93,7 @@ func MoveGroupItem(ctx context.Context, opts MoveGroupOptions, doer *user_model.
return err
}
if !canAccessNewParent {
return fmt.Errorf("cannot access new parent group")
return errors.New("cannot access new parent group")
}
err = parentGroup.LoadSubgroups(ctx, false)

View File

@ -1,3 +1,6 @@
// Copyright 2025 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package group
import (
@ -42,7 +45,12 @@ func TestMoveGroup(t *testing.T) {
}
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)
}
testfn(124)
@ -60,6 +68,11 @@ func TestMoveRepo(t *testing.T) {
})
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)
}

View File

@ -1,12 +1,15 @@
// Copyright 2025 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package group
import (
"code.gitea.io/gitea/models/perm"
"context"
"slices"
"code.gitea.io/gitea/models/git"
group_model "code.gitea.io/gitea/models/group"
"code.gitea.io/gitea/models/perm"
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unit"
user_model "code.gitea.io/gitea/models/user"
@ -103,7 +106,7 @@ func (w *WebSearchGroup) doLoadChildren(opts *WebSearchOptions) error {
wsr.LatestCommitStatus = latestCommitStatuses[i]
wsr.LocaleLatestCommitStatus = latestCommitStatuses[i].LocaleString(opts.Locale)
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
}
} else {

View File

@ -1,3 +1,6 @@
// Copyright 2025 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package group
import (
@ -68,7 +71,7 @@ func UpdateGroupTeam(ctx context.Context, gt *group_model.RepoGroupTeam) (err er
And("group_id=?", gt.GroupID).
And("type = ?", unit.Type).
Update(unit); err != nil {
return
return err
}
}
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)
}
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 {
return err
}
@ -110,7 +113,6 @@ func RecalculateGroupAccess(ctx context.Context, g *group_model.Group, isNew boo
return err
}
for _, u := range t.Units {
newAccessMode := u.AccessMode
if g.ParentGroup == nil {
gu, err := group_model.GetGroupUnit(ctx, g.ID, t.ID, u.Type)

View File

@ -1,3 +1,6 @@
// Copyright 2025 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package group
import (