Skip to content

Commit 7d20c83

Browse files
authored
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.
1 parent 4c0fce8 commit 7d20c83

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

models/migrations/v219.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"code.gitea.io/gitea/models/repo"
1111
"code.gitea.io/gitea/modules/timeutil"
12+
1213
"xorm.io/xorm"
1314
)
1415

modules/git/git.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020

2121
"code.gitea.io/gitea/modules/log"
2222
"code.gitea.io/gitea/modules/setting"
23+
2324
"github.com/hashicorp/go-version"
2425
)
2526

routers/web/repo/view.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -854,15 +854,15 @@ func renderDirectoryFiles(ctx *context.Context, timeout time.Duration) git.Entri
854854
}
855855
ctx.Data["LatestCommitVerification"] = verification
856856
ctx.Data["LatestCommitUser"] = user_model.ValidateCommitWithEmail(latestCommit)
857-
}
858857

859-
statuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, ctx.Repo.Commit.ID.String(), db.ListOptions{})
860-
if err != nil {
861-
log.Error("GetLatestCommitStatus: %v", err)
862-
}
858+
statuses, _, err := git_model.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, latestCommit.ID.String(), db.ListOptions{})
859+
if err != nil {
860+
log.Error("GetLatestCommitStatus: %v", err)
861+
}
863862

864-
ctx.Data["LatestCommitStatus"] = git_model.CalcCommitStatus(statuses)
865-
ctx.Data["LatestCommitStatuses"] = statuses
863+
ctx.Data["LatestCommitStatus"] = git_model.CalcCommitStatus(statuses)
864+
ctx.Data["LatestCommitStatuses"] = statuses
865+
}
866866

867867
branchLink := ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL()
868868
treeLink := branchLink

0 commit comments

Comments
 (0)