fix(team): show public teams to non-members

Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
bircni committed 2026-10-18 17:16:19 +02:00
1 parent 51c436ef11
commit 064dbc1cbd
2 files changed
+14 -2

No files matched your search

+8 -2
View File
@@ -184,8 +184,10 @@ $ tea team view 2 --json units`,
if a.options.json != "" {
return a.writeJSON(cmd, team)
}
// Gitea shows a public team to non-members of its organization, but not its members.
members, err := service.Members(cmd.Context(), team.ID, teamViewNames, 1)
if err != nil {
membersHidden := services.IsForbidden(err)
if err != nil && !membersHidden {
return err
}
repos, err := service.Repositories(cmd.Context(), team.ID, teamViewNames, 1)
@@ -199,6 +201,10 @@ $ tea team view 2 --json units`,
units = append(units, strings.TrimPrefix(unit, "repo.")+": "+access)
}
}
memberNames := ""
if !membersHidden {
memberNames = listedNames(members, func(member services.OrganizationMember) string { return member.Username })
}
repositories := listedNames(repos, func(repo services.Repository) string { return repo.FullName })
if team.AllRepositories {
repositories = "all repositories of " + team.Organization
@@ -208,7 +214,7 @@ $ tea team view 2 --json units`,
Fields: []terminal.Field{
{Label: "Access", Value: team.Access(), PipedOnly: true},
{Label: "Units", Value: strings.Join(units, ", ")},
{Label: "Members", Value: listedNames(members, func(member services.OrganizationMember) string { return member.Username })},
{Label: "Members", Value: memberNames},
{Label: "Repositories", Value: repositories},
{Label: "Can create repos", Value: yesNo(team.CanCreateRepo)},
},
+6
View File
@@ -198,6 +198,12 @@ func IsNotFound(err error) bool {
return ok && failure.Status == http.StatusNotFound
}
// IsForbidden reports whether err is a 403 response.
func IsForbidden(err error) bool {
failure, ok := errors.AsType[*transport.APIError](err)
return ok && failure.Status == http.StatusForbidden
}
// refusal returns the conflict reason of a refused request, or "".
func refusal(apiErr *transport.APIError) string {
if apiErr.Status == http.StatusLocked {