Skip to content

Commit

Permalink
Fix commit status icon when in subdirectory (go-gitea#20285)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
silverwind committed Jul 15, 2022
1 parent 4c0fce8 commit 7d20c83
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions models/migrations/v219.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/modules/timeutil"

"xorm.io/xorm"
)

Expand Down
1 change: 1 addition & 0 deletions modules/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"

"github.com/hashicorp/go-version"
)

Expand Down
14 changes: 7 additions & 7 deletions routers/web/repo/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7d20c83

Please sign in to comment.