From 7d20c8323a9d5d48631d7eb793dcd2d19b25f6d4 Mon Sep 17 00:00:00 2001 From: silverwind Date: Fri, 15 Jul 2022 15:01:32 +0200 Subject: [PATCH] Fix commit status icon when in subdirectory (#20285) When viewing a subdirectory and the latest commit to that directory in the table, the commit status icon incorrectly showed the status of the HEAD commit instead of the latest for that directory. --- models/migrations/v219.go | 1 + modules/git/git.go | 1 + routers/web/repo/view.go | 14 +++++++------- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/models/migrations/v219.go b/models/migrations/v219.go index 7b2eaa3292..7b4f34b704 100644 --- a/models/migrations/v219.go +++ b/models/migrations/v219.go @@ -9,6 +9,7 @@ import ( "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/modules/timeutil" + "xorm.io/xorm" ) diff --git a/modules/git/git.go b/modules/git/git.go index 3bc08ff93b..b8317396c0 100644 --- a/modules/git/git.go +++ b/modules/git/git.go @@ -20,6 +20,7 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" + "github.com/hashicorp/go-version" ) diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go index 17169699df..6b6660f774 100644 --- a/routers/web/repo/view.go +++ b/routers/web/repo/view.go @@ -854,15 +854,15 @@ func renderDirectoryFiles(ctx *context.Context, timeout time.Duration) git.Entri } ctx.Data["LatestCommitVerification"] = verification ctx.Data["LatestCommitUser"] = user_model.ValidateCommitWithEmail(latestCommit) - } - statuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, ctx.Repo.Commit.ID.String(), db.ListOptions{}) - if err != nil { - log.Error("GetLatestCommitStatus: %v", err) - } + statuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, latestCommit.ID.String(), db.ListOptions{}) + if err != nil { + log.Error("GetLatestCommitStatus: %v", err) + } - ctx.Data["LatestCommitStatus"] = git_model.CalcCommitStatus(statuses) - ctx.Data["LatestCommitStatuses"] = statuses + ctx.Data["LatestCommitStatus"] = git_model.CalcCommitStatus(statuses) + ctx.Data["LatestCommitStatuses"] = statuses + } branchLink := ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL() treeLink := branchLink