Skip to content

Commit

Permalink
Set commit id when ref used explicitly (#26447)
Browse files Browse the repository at this point in the history
In the `RepoRefForAPI()` context function `CommitID` is not set if `ref`
is used. It is set correctly for other if/else branches where `Commit`
is set. It doesn't appear that any routes that use `RepoRefForAPI()`
also use `CommitID` but that may be the case in the future.

## Changes
- Sets `ctx.Repo.CommitID` when `ref` is explicitly used for api routes
that use `RepoRefForAPI()`
  • Loading branch information
jackHay22 committed Aug 12, 2023
1 parent 9fc68b6 commit c5888eb
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions modules/context/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ func RepoRefForAPI(next http.Handler) http.Handler {
return
}
ctx.Repo.Commit = commit
ctx.Repo.CommitID = ctx.Repo.Commit.ID.String()
ctx.Repo.TreePath = ctx.Params("*")
next.ServeHTTP(w, req)
return
Expand Down

0 comments on commit c5888eb

Please sign in to comment.