Skip to content

[1/3] subgroups #35265

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

Draft
wants to merge 97 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
6e0917f
begin work on base subfeatures
GamerGirlandCo Aug 13, 2025
32ca039
add group model
GamerGirlandCo Dec 25, 2024
63b97fc
create GroupList type and methods
GamerGirlandCo Dec 25, 2024
f24f1e6
add `Group` methods and helper functions
GamerGirlandCo Dec 25, 2024
ab82f67
add avatar to group
GamerGirlandCo Dec 28, 2024
a9e3ee5
add `ParentGroup` field and related `LoadParentGroup` method to `Grou…
GamerGirlandCo Dec 28, 2024
817a9f2
add `GroupTeam` and `GroupUnit` structs and helpers
GamerGirlandCo Dec 28, 2024
e5dd5e9
add condition and builder functions to be used when searching for groups
GamerGirlandCo Dec 28, 2024
21526f8
add `OwnerName` field to `Group` struct
GamerGirlandCo Dec 28, 2024
d77e2a6
rename `DisplayName` -> `FullName` for consistency
GamerGirlandCo Dec 28, 2024
227e59d
add `IsPrivate` and `Visibility` fields to `Group` struct
GamerGirlandCo Dec 28, 2024
0ce8b79
add `FindGroupsByCond` helper function
GamerGirlandCo Dec 28, 2024
aa79e1b
fix nonexistent variable reference in `GetGroupByID` function
GamerGirlandCo Dec 28, 2024
ac9892f
add `GroupLink` method to `Group` struct
GamerGirlandCo Dec 28, 2024
ac33856
add helper functions for dealing with group hierarchies
GamerGirlandCo Dec 28, 2024
35c789d
refactor subgroup loading, add method to load only groups accessible …
GamerGirlandCo Dec 28, 2024
639b627
register `GroupTeam` and `GroupUnit` models
GamerGirlandCo Dec 28, 2024
3df182f
add condition and builder functions to be used when searching for groups
GamerGirlandCo Dec 28, 2024
7f74545
changes
GamerGirlandCo Jan 9, 2025
6c85e2f
update group model
GamerGirlandCo Jan 9, 2025
b201600
add `UserOrgTeamPermCond` function
GamerGirlandCo Jan 9, 2025
a3a44c8
add new fields and methods to `GroupTeam` model
GamerGirlandCo Jan 9, 2025
a612627
update group_unit.go
GamerGirlandCo Jan 9, 2025
70f44fa
remove unused parameter from `Group.relAvatarLink` method
GamerGirlandCo Jan 9, 2025
234be4c
[models] update repo model
GamerGirlandCo Jan 9, 2025
33e397a
update repo_permission.go
GamerGirlandCo Jan 9, 2025
061bdbe
add conversion functions for repository groups
GamerGirlandCo Jan 9, 2025
1ad2357
add file with functions relating to organization teams and repo groups
GamerGirlandCo Jan 9, 2025
088cf5c
update `team_list.go`
GamerGirlandCo Jan 9, 2025
ff8b8e3
add group-related url segments to list of reserved usernames
GamerGirlandCo Jan 9, 2025
d17ab88
[models/search-options] add `GroupID` to `SearchRepoOptions`
GamerGirlandCo Jan 9, 2025
590a621
[models/conds] add functions returning builders to help find repos ma…
GamerGirlandCo Jan 10, 2025
5655ea9
[models/conds] update some repo conditions to check for access provid…
GamerGirlandCo Jan 10, 2025
f7077a0
[models] update `GetTeamRepositories` to also return repositories acc…
GamerGirlandCo Jan 10, 2025
bcb4b6f
[services] ensure `OwnerName` field is updated in groups owned by an …
GamerGirlandCo Jan 10, 2025
6c0dbf2
[misc] update avatar utils to handle group avatars
GamerGirlandCo Jan 10, 2025
d4e9803
fix duplicate teams being returned by `GetTeamsWithAccessToGroup`
GamerGirlandCo Jul 20, 2025
3b95289
fix bug where all repos are returned even when `opts.GroupID` == 0
GamerGirlandCo Jul 20, 2025
f6a7ae5
remove unused/redundant `IsPrivate` field from Group struct
GamerGirlandCo Aug 11, 2025
3f9a905
add `UpdateGroup` function
GamerGirlandCo Aug 11, 2025
b9f6946
[services] update `MoveGroupItem` function to set `newPos` to the len…
GamerGirlandCo Aug 11, 2025
69847ef
add missing nil check before `IsErrGroupNotExist` call
GamerGirlandCo Aug 13, 2025
a45142f
add test fixtures
GamerGirlandCo Aug 13, 2025
bce268b
fix `no columns found to update` error when recalculating group access
GamerGirlandCo Aug 13, 2025
e985ca5
add some unit tests for group service
GamerGirlandCo Aug 13, 2025
d75ed6c
fix deadlock caused by differing contexts when retrieving group ances…
GamerGirlandCo Aug 13, 2025
3357767
re-add `PermissionNoAccess` function
GamerGirlandCo Aug 13, 2025
88e4535
add `GroupID` field to `CreateRepoOptions`
GamerGirlandCo Aug 13, 2025
20468e5
fix build error caused by changed function name
GamerGirlandCo Aug 13, 2025
c2d30e0
add `GroupID` and `GroupSortOrder` fields to `Repository` api struct
GamerGirlandCo Aug 13, 2025
cea8af1
fix more build errors
GamerGirlandCo Aug 13, 2025
3e366ed
add api types for groups
GamerGirlandCo Aug 13, 2025
a239b7c
fix a few more build errors
GamerGirlandCo Aug 13, 2025
55cc277
regenerate swagger definitions
GamerGirlandCo Aug 13, 2025
c603713
format files
GamerGirlandCo Aug 13, 2025
e378717
reapply changes wiped out by conflict resolution
GamerGirlandCo Aug 13, 2025
4e6694f
add ownership check when moving repository to a new group
GamerGirlandCo Aug 13, 2025
2ebfa2e
apply simple linting changes
GamerGirlandCo Aug 13, 2025
457044e
apply simple linting changes
GamerGirlandCo Aug 13, 2025
a543cfb
update repo service to check that `GroupID` is owned by the repo owne…
GamerGirlandCo Aug 14, 2025
93d0e6a
move parameters of the `MoveGroup` function into a struct, `MoveGroup…
GamerGirlandCo Aug 14, 2025
9745994
rename tables in group-related query conditions
GamerGirlandCo Aug 14, 2025
fc85f5f
add api routes and functions for repository groups
GamerGirlandCo Aug 14, 2025
6ff1eba
add `doer` parameter to `MoveGroupItem` describing the user trying to…
GamerGirlandCo Aug 14, 2025
947fcb0
update `AccessibleGroupCondition` function to take a minimum `perm.Ac…
GamerGirlandCo Aug 14, 2025
16e7fef
remove bare return
GamerGirlandCo Aug 14, 2025
a8ca76e
run formatter
GamerGirlandCo Aug 14, 2025
e177ce7
move group routes that don't depend on the `org` path parameter out o…
GamerGirlandCo Aug 14, 2025
849fd54
add appropriate swagger definitions
GamerGirlandCo Aug 14, 2025
5a408cf
refactor group creation such that we know the owner ID ahead of time,…
GamerGirlandCo Aug 14, 2025
54fe70a
fix swagger definition references to nonexistent `CreateGroupOption`
GamerGirlandCo Aug 14, 2025
16d5d76
add api routes and functions to get a repository group's subgroups an…
GamerGirlandCo Aug 14, 2025
b71e6de
fix build errors
GamerGirlandCo Aug 14, 2025
fc3112f
fix build and lint errors
GamerGirlandCo Aug 14, 2025
cadaf4a
fix failing tests ?
GamerGirlandCo Aug 14, 2025
6c4d70d
ensure we return early if there was an error loading group units
GamerGirlandCo Aug 16, 2025
c925824
fix bug where `builder.In` cond for groups and teams was not placed i…
GamerGirlandCo Aug 16, 2025
1cf163f
remove `UNIQUE` constraint on `Group.LowerName`
GamerGirlandCo Aug 16, 2025
d7f1cbc
add explicit `TEXT` type to `Group.LowerName` tag
GamerGirlandCo Aug 16, 2025
c3a2641
add/remove more constraints for mssql/mysql compatibility
GamerGirlandCo Aug 16, 2025
b3656c0
rename test fixture files for group units and teams
GamerGirlandCo Aug 16, 2025
b28c4f9
fix more failing tests
GamerGirlandCo Aug 16, 2025
ae7a9d5
add indices to group_id and group_sort_order column
GamerGirlandCo Aug 17, 2025
4eeec9a
add `AvatarURL` field to api groups (in `modules/structs` package)
GamerGirlandCo Aug 16, 2025
2b0e45d
update repository storage layout as per https://github.com/go-gitea/g…
GamerGirlandCo Aug 17, 2025
a93c572
update API routes as well
GamerGirlandCo Aug 17, 2025
a6327b2
fix optional path segments not working out as planned
GamerGirlandCo Aug 18, 2025
5322907
update `FullName` method to show group id if it's non-zero
GamerGirlandCo Aug 18, 2025
f586d41
add group ID column to repository table's unique constraint
GamerGirlandCo Aug 18, 2025
53ff433
add group id segment to repository's `Link` method
GamerGirlandCo Aug 18, 2025
c3aed71
fix broken hooks
GamerGirlandCo Aug 18, 2025
f79fca7
make it more apparent in URLs that a repo is part of a group
GamerGirlandCo Aug 18, 2025
72995d9
fix broken hooks (again)
GamerGirlandCo Aug 18, 2025
f4b2ae3
ensure that repository is moved on disk in `MoveGroupItem` function
GamerGirlandCo Aug 18, 2025
1a7ee73
fix moving items to the root-level (`GroupID` <= 0)
GamerGirlandCo Aug 18, 2025
37f9752
fix bug where a repo's group id and group sort order are zero in API …
GamerGirlandCo Aug 22, 2025
ef8eb1f
ensure visited repo's group owner is the same as the repo's owner, ot…
GamerGirlandCo Aug 22, 2025
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
17 changes: 10 additions & 7 deletions cmd/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ Gitea or set your environment appropriately.`, "")
// the environment is set by serv command
isWiki, _ := strconv.ParseBool(os.Getenv(repo_module.EnvRepoIsWiki))
username := os.Getenv(repo_module.EnvRepoUsername)
groupID, _ := strconv.ParseInt(os.Getenv(repo_module.EnvRepoGroupID), 10, 64)
reponame := os.Getenv(repo_module.EnvRepoName)
userID, _ := strconv.ParseInt(os.Getenv(repo_module.EnvPusherID), 10, 64)
prID, _ := strconv.ParseInt(os.Getenv(repo_module.EnvPRID), 10, 64)
Expand Down Expand Up @@ -254,7 +255,7 @@ Gitea or set your environment appropriately.`, "")
hookOptions.OldCommitIDs = oldCommitIDs
hookOptions.NewCommitIDs = newCommitIDs
hookOptions.RefFullNames = refFullNames
extra := private.HookPreReceive(ctx, username, reponame, hookOptions)
extra := private.HookPreReceive(ctx, username, reponame, groupID, hookOptions)
if extra.HasError() {
return fail(ctx, extra.UserMsg, "HookPreReceive(batch) failed: %v", extra.Error)
}
Expand All @@ -277,7 +278,7 @@ Gitea or set your environment appropriately.`, "")

fmt.Fprintf(out, " Checking %d references\n", count)

extra := private.HookPreReceive(ctx, username, reponame, hookOptions)
extra := private.HookPreReceive(ctx, username, reponame, groupID, hookOptions)
if extra.HasError() {
return fail(ctx, extra.UserMsg, "HookPreReceive(last) failed: %v", extra.Error)
}
Expand Down Expand Up @@ -350,6 +351,7 @@ Gitea or set your environment appropriately.`, "")
pusherID, _ := strconv.ParseInt(os.Getenv(repo_module.EnvPusherID), 10, 64)
prID, _ := strconv.ParseInt(os.Getenv(repo_module.EnvPRID), 10, 64)
pusherName := os.Getenv(repo_module.EnvPusherName)
groupID, _ := strconv.ParseInt(os.Getenv(repo_module.EnvRepoGroupID), 10, 64)

hookOptions := private.HookOptions{
UserName: pusherName,
Expand Down Expand Up @@ -399,7 +401,7 @@ Gitea or set your environment appropriately.`, "")
hookOptions.OldCommitIDs = oldCommitIDs
hookOptions.NewCommitIDs = newCommitIDs
hookOptions.RefFullNames = refFullNames
resp, extra := private.HookPostReceive(ctx, repoUser, repoName, hookOptions)
resp, extra := private.HookPostReceive(ctx, repoUser, repoName, groupID, hookOptions)
if extra.HasError() {
_ = dWriter.Close()
hookPrintResults(results)
Expand All @@ -414,7 +416,7 @@ Gitea or set your environment appropriately.`, "")
if count == 0 {
if wasEmpty && masterPushed {
// We need to tell the repo to reset the default branch to master
extra := private.SetDefaultBranch(ctx, repoUser, repoName, "master")
extra := private.SetDefaultBranch(ctx, repoUser, repoName, groupID, "master")
if extra.HasError() {
return fail(ctx, extra.UserMsg, "SetDefaultBranch failed: %v", extra.Error)
}
Expand All @@ -432,7 +434,7 @@ Gitea or set your environment appropriately.`, "")

fmt.Fprintf(out, " Processing %d references\n", count)

resp, extra := private.HookPostReceive(ctx, repoUser, repoName, hookOptions)
resp, extra := private.HookPostReceive(ctx, repoUser, repoName, groupID, hookOptions)
if resp == nil {
_ = dWriter.Close()
hookPrintResults(results)
Expand All @@ -445,7 +447,7 @@ Gitea or set your environment appropriately.`, "")

if wasEmpty && masterPushed {
// We need to tell the repo to reset the default branch to master
extra := private.SetDefaultBranch(ctx, repoUser, repoName, "master")
extra := private.SetDefaultBranch(ctx, repoUser, repoName, groupID, "master")
if extra.HasError() {
return fail(ctx, extra.UserMsg, "SetDefaultBranch failed: %v", extra.Error)
}
Expand Down Expand Up @@ -513,6 +515,7 @@ Gitea or set your environment appropriately.`, "")
repoName := os.Getenv(repo_module.EnvRepoName)
pusherID, _ := strconv.ParseInt(os.Getenv(repo_module.EnvPusherID), 10, 64)
pusherName := os.Getenv(repo_module.EnvPusherName)
groupID, _ := strconv.ParseInt(os.Getenv(repo_module.EnvRepoGroupID), 10, 64)

// 1. Version and features negotiation.
// S: PKT-LINE(version=1\0push-options atomic...) / PKT-LINE(version=1\n)
Expand Down Expand Up @@ -626,7 +629,7 @@ Gitea or set your environment appropriately.`, "")
}

// 3. run hook
resp, extra := private.HookProcReceive(ctx, repoUser, repoName, hookOptions)
resp, extra := private.HookProcReceive(ctx, repoUser, repoName, groupID, hookOptions)
if extra.HasError() {
return fail(ctx, extra.UserMsg, "HookProcReceive failed: %v", extra.Error)
}
Expand Down
Loading
Loading