0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-05-11 11:25:42 +02:00

update activity actions to return paths/links with a repo's group

This commit is contained in:
☙◦ The Tablet ❀ GamerGirlandCo ◦❧ 2025-11-22 20:31:06 -05:00
parent 96464507a9
commit 03a3195e8e
No known key found for this signature in database
GPG Key ID: 924A5F6AF051E87C
2 changed files with 19 additions and 3 deletions

View File

@ -259,6 +259,14 @@ func (a *Action) GetRepoName(ctx context.Context) string {
return a.Repo.Name
}
func (a *Action) GetRepoGroup(ctx context.Context) string {
_ = a.LoadRepo(ctx)
if a.Repo == nil || a.Repo.GroupID == 0 {
return ""
}
return strconv.FormatInt(a.Repo.GroupID, 10)
}
// ShortRepoName returns the name of the action repository
// trimmed to max 33 chars.
func (a *Action) ShortRepoName(ctx context.Context) string {
@ -267,19 +275,26 @@ func (a *Action) ShortRepoName(ctx context.Context) string {
// GetRepoPath returns the virtual path to the action repository.
func (a *Action) GetRepoPath(ctx context.Context) string {
return path.Join(a.GetRepoUserName(ctx), a.GetRepoName(ctx))
return path.Join(a.GetRepoUserName(ctx), a.GetRepoGroup(ctx), a.GetRepoName(ctx))
}
// ShortRepoPath returns the virtual path to the action repository
// trimmed to max 20 + 1 + 33 chars.
func (a *Action) ShortRepoPath(ctx context.Context) string {
return path.Join(a.ShortRepoUserName(ctx), a.ShortRepoName(ctx))
return path.Join(a.ShortRepoUserName(ctx), a.makeGroupSegment(ctx), a.GetRepoGroup(ctx), a.ShortRepoName(ctx))
}
// GetRepoLink returns relative link to action repository.
func (a *Action) GetRepoLink(ctx context.Context) string {
// path.Join will skip empty strings
return path.Join(setting.AppSubURL, "/", url.PathEscape(a.GetRepoUserName(ctx)), url.PathEscape(a.GetRepoName(ctx)))
return path.Join(setting.AppSubURL, "/", url.PathEscape(a.GetRepoUserName(ctx)), a.makeGroupSegment(ctx), a.GetRepoGroup(ctx), url.PathEscape(a.GetRepoName(ctx)))
}
func (a *Action) makeGroupSegment(ctx context.Context) string {
if a.GetRepoGroup(ctx) != "" {
return "group"
}
return ""
}
// GetRepoAbsoluteLink returns the absolute link to action repository.

View File

@ -58,6 +58,7 @@ type Actioner interface {
GetActUserName(ctx context.Context) string
GetRepoUserName(ctx context.Context) string
GetRepoName(ctx context.Context) string
GetRepoGroup(ctx context.Context) string
GetRepoPath(ctx context.Context) string
GetRepoLink(ctx context.Context) string
GetBranch() string