feat: show last commit message in org recent activity section
Some checks failed
Build and Release / Build Binaries (amd64, darwin) (push) Blocked by required conditions
Build and Release / Build Binaries (amd64, linux) (push) Blocked by required conditions
Build and Release / Build Binaries (amd64, windows) (push) Blocked by required conditions
Build and Release / Build Binaries (arm64, darwin) (push) Blocked by required conditions
Build and Release / Build Binaries (arm64, linux) (push) Blocked by required conditions
Build and Release / Create Release (push) Has been skipped
Build and Release / Unit Tests (push) Has been cancelled
Build and Release / Lint (push) Has been cancelled
Build and Release / Integration Tests (PostgreSQL) (push) Has been cancelled

This commit is contained in:
David H Friedel Jr 2026-01-11 03:25:30 +00:00
parent 3fb751bc24
commit 67ff066157
2 changed files with 39 additions and 19 deletions

View File

@ -17,11 +17,19 @@ import (
"code.gitea.io/gitea/modules/markup/markdown"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/templates"
"code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/util"
shared_user "code.gitea.io/gitea/routers/web/shared/user"
"code.gitea.io/gitea/services/context"
org_service "code.gitea.io/gitea/services/org"
)
// RecentRepoActivity holds repo and its latest commit info
type RecentRepoActivity struct {
Repo *repo_model.Repository
CommitMessage string
CommitTime timeutil.TimeStamp
}
const tplOrgHome templates.TplName = "org/home"
@ -119,7 +127,25 @@ func home(ctx *context.Context, viewRepositories bool) {
if err != nil {
log.Error("SearchRepository for recent repos: %v", err)
} else {
ctx.Data["RecentRepos"] = recentRepos
// Load commit info for each repo
var recentActivity []*RecentRepoActivity
for _, repo := range recentRepos {
activity := &RecentRepoActivity{Repo: repo}
gitRepo, err := git.OpenRepository(ctx, repo.RepoPath())
if err == nil {
commit, err := gitRepo.GetBranchCommit(repo.DefaultBranch)
if err == nil {
activity.CommitMessage = commit.Summary()
activity.CommitTime = timeutil.TimeStamp(commit.Author.When.Unix())
}
gitRepo.Close()
}
recentActivity = append(recentActivity, activity)
}
ctx.Data["RecentActivity"] = recentActivity
}
prepareResult, err := shared_user.RenderUserOrgHeader(ctx)

View File

@ -33,7 +33,7 @@
<div class="content">
<div class="header tw-flex tw-items-center tw-gap-2">
{{if .Repo.Avatar}}
<img class="tw-w-6 tw-h-6 tw-rounded" src="{{.Repo.RelAvatarLink ctx}}" alt="">
<img class="tw-max-w-20 tw-max-h-20 tw-rounded tw-object-contain" src="{{.Repo.Repo.RelAvatarLink ctx}}" alt="">
{{else}}
{{if .Repo.IsPrivate}}{{svg "octicon-lock" 16}}{{else if .Repo.IsFork}}{{svg "octicon-repo-forked" 16}}{{else if .Repo.IsMirror}}{{svg "octicon-mirror" 16}}{{else}}{{svg "octicon-repo" 16}}{{end}}
{{end}}
@ -78,7 +78,7 @@
<div class="content">
<div class="header tw-flex tw-items-center tw-gap-2">
{{if .Repo.Avatar}}
<img class="tw-w-6 tw-h-6 tw-rounded" src="{{.Repo.RelAvatarLink ctx}}" alt="">
<img class="tw-max-w-20 tw-max-h-20 tw-rounded tw-object-contain" src="{{.Repo.Repo.RelAvatarLink ctx}}" alt="">
{{else}}
{{if .Repo.IsPrivate}}{{svg "octicon-lock" 16}}{{else if .Repo.IsFork}}{{svg "octicon-repo-forked" 16}}{{else if .Repo.IsMirror}}{{svg "octicon-mirror" 16}}{{else}}{{svg "octicon-repo" 16}}{{end}}
{{end}}
@ -155,36 +155,30 @@
{{end}}
{{/* Recent Activity Section */}}
{{if .RecentRepos}}
{{if .RecentActivity}}
<div class="ui segment tw-mt-4">
<h4 class="ui header tw-flex tw-items-center">
{{svg "octicon-pulse" 16}} {{ctx.Locale.Tr "org.recent_activity"}}
</h4>
<div class="ui relaxed divided list">
{{range .RecentRepos}}
{{range .RecentActivity}}
<div class="item">
<div class="tw-flex tw-items-center tw-gap-3">
{{if .Avatar}}
<img class="tw-w-8 tw-h-8 tw-rounded" src="{{.RelAvatarLink ctx}}" alt="">
{{if .Repo.Avatar}}
<img class="tw-max-w-20 tw-max-h-20 tw-rounded tw-object-contain" src="{{.Repo.RelAvatarLink ctx}}" alt="">
{{else}}
<div class="tw-w-8 tw-h-8 tw-flex tw-items-center tw-justify-center">
{{if .IsPrivate}}{{svg "octicon-lock" 20}}{{else if .IsFork}}{{svg "octicon-repo-forked" 20}}{{else if .IsMirror}}{{svg "octicon-mirror" 20}}{{else}}{{svg "octicon-repo" 20}}{{end}}
{{if .Repo.IsPrivate}}{{svg "octicon-lock" 20}}{{else if .Repo.IsFork}}{{svg "octicon-repo-forked" 20}}{{else if .Repo.IsMirror}}{{svg "octicon-mirror" 20}}{{else}}{{svg "octicon-repo" 20}}{{end}}
</div>
{{end}}
<div class="tw-flex-1 tw-min-w-0">
<a href="{{.Link}}" class="tw-font-semibold">{{.Name}}</a>
{{if .Description}}
<p class="text grey tw-text-sm tw-truncate tw-mb-0">{{.Description}}</p>
<a href="{{.Repo.Link}}" class="tw-font-semibold">{{.Repo.Name}}</a>
{{if .CommitMessage}}
<p class="text grey tw-text-sm tw-truncate tw-mb-0">{{.CommitMessage}}</p>
{{end}}
</div>
<div class="tw-text-right tw-text-sm text grey tw-flex-shrink-0">
{{if .PrimaryLanguage}}
<span class="tw-mr-2">
<span class="repo-language-color" style="background-color: {{.PrimaryLanguage.Color}}"></span>
{{.PrimaryLanguage.Language}}
</span>
{{end}}
<span title="{{DateUtils.FullTime .UpdatedUnix}}">{{DateUtils.TimeSince .UpdatedUnix}}</span>
<span title="{{DateUtils.FullTime .CommitTime}}">{{DateUtils.TimeSince .CommitTime}}</span>
</div>
</div>
</div>
@ -284,7 +278,7 @@
<div class="ui attached table segment teams">
{{range .Teams}}
<div class="item">
<a href="{{$.OrgLink}}/teams/{{.LowerName | PathEscape}}"><strong class="team-name">{{.Name}}</strong></a>
<a href="{{$.OrgLink}}/teams/{{.LowerName | PathEscape}}"><strong class="team-name">{{.Repo.Name}}</strong></a>
<p class="text grey">
<a class="muted" href="{{$.OrgLink}}/teams/{{.LowerName | PathEscape}}"><strong>{{.NumMembers}}</strong> {{ctx.Locale.Tr "org.lower_members"}}</a> ·
<a class="muted" href="{{$.OrgLink}}/teams/{{.LowerName | PathEscape}}/repositories"><strong>{{.NumRepos}}</strong> {{ctx.Locale.Tr "org.lower_repositories"}}</a>