]> source.dussan.org Git - gitea.git/commitdiff
Set commit id when ref used explicitly (#26447)
authorJack Hay <jack@allspice.io>
Sat, 12 Aug 2023 07:33:12 +0000 (03:33 -0400)
committerGitHub <noreply@github.com>
Sat, 12 Aug 2023 07:33:12 +0000 (07:33 +0000)
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()`

modules/context/api.go

index a367597e8a44ea61333625414b3da125e49a0c3c..58532b883dde0a75579fb2a7ea23f38c3576ce99 100644 (file)
@@ -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