diff options
author | silverwind <me@silverwind.io> | 2022-07-16 14:54:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-16 14:54:49 +0200 |
commit | 3f5d72709f46472655e871a8a7e51741c71e84ec (patch) | |
tree | b3ae63f3efdfd4c3ef93f556b4042905141961d6 | |
parent | 95a27eb662ae1ecf837ad6a89e2254a9e02d18ff (diff) | |
download | gitea-3f5d72709f46472655e871a8a7e51741c71e84ec.tar.gz gitea-3f5d72709f46472655e871a8a7e51741c71e84ec.zip |
Fix commit status icon when in subdirectory (#20285) (#20385)
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.
-rw-r--r-- | modules/git/git.go | 1 | ||||
-rw-r--r-- | routers/web/repo/view.go | 14 |
2 files changed, 8 insertions, 7 deletions
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 c327f959f6..169c6fa82d 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 |