From 4131cc4159e6134854a1d2485dc931320ce4ed5b Mon Sep 17 00:00:00 2001 From: Gusted Date: Fri, 22 May 2026 10:40:28 +0200 Subject: [PATCH] ench: use GET for lastcommit route (#12670) When it was introduced the route did receive for which entries it should get the last commit for. It was refactored in 1e29bccddb to HTMX and now simply gets the last commit for all entries. In the spirit of using the correct HTTP methods, switch it to GET. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/12670 Reviewed-by: Mathieu Fenniak --- routers/web/web.go | 2 +- templates/repo/view_list.tmpl | 2 +- tests/integration/repo_commit_test.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/routers/web/web.go b/routers/web/web.go index bf9bb9be6e..b23ab738bf 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -1743,7 +1743,7 @@ func registerRoutes(m *web.Route) { m.Post("/sync_fork", context.RepoMustNotBeArchived(), repo.MustBeNotEmpty, reqRepoCodeWriter, repo.SyncFork) }, ignSignIn, context.RepoAssignment, context.UnitTypes()) - m.Post("/{username}/{reponame}/lastcommit/*", ignSignIn, context.RepoAssignment, context.UnitTypes(), context.RepoRefByType(context.RepoRefCommit), reqRepoCodeReader, repo.LastCommit) + m.Get("/{username}/{reponame}/lastcommit/*", ignSignIn, context.RepoAssignment, context.UnitTypes(), context.RepoRefByType(context.RepoRefCommit), reqRepoCodeReader, repo.LastCommit) m.Group("/{username}/{reponame}", func() { if !setting.Repository.DisableStars { diff --git a/templates/repo/view_list.tmpl b/templates/repo/view_list.tmpl index cc583d18c7..038c3d6d3b 100644 --- a/templates/repo/view_list.tmpl +++ b/templates/repo/view_list.tmpl @@ -1,4 +1,4 @@ - +
diff --git a/tests/integration/repo_commit_test.go b/tests/integration/repo_commit_test.go index 0975e48c0c..6a1fbbaf56 100644 --- a/tests/integration/repo_commit_test.go +++ b/tests/integration/repo_commit_test.go @@ -87,14 +87,14 @@ func TestLastCommit(t *testing.T) { defer tests.PrepareTestEnv(t)() t.Run("Anonymous", func(t *testing.T) { - req := NewRequest(t, "POST", "/user2/repo1/lastcommit/65f1bf27bc3bf70f64657658635e66094edbcb4d") + req := NewRequest(t, "GET", "/user2/repo1/lastcommit/65f1bf27bc3bf70f64657658635e66094edbcb4d") MakeRequest(t, req, http.StatusOK) }) t.Run("Signed in", func(t *testing.T) { session := loginUser(t, "user2") - req := NewRequest(t, "POST", "/user2/repo1/lastcommit/65f1bf27bc3bf70f64657658635e66094edbcb4d") + req := NewRequest(t, "GET", "/user2/repo1/lastcommit/65f1bf27bc3bf70f64657658635e66094edbcb4d") session.MakeRequest(t, req, http.StatusOK) }) }
{{ctx.Locale.Tr "repo.files.caption"}}