Skip to content

Commit 4131cc4

Browse files
GustedGusted
authored andcommitted
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 1e29bcc 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 <mfenniak@noreply.codeberg.org>
1 parent 294952b commit 4131cc4

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

routers/web/web.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1743,7 +1743,7 @@ func registerRoutes(m *web.Route) {
17431743
m.Post("/sync_fork", context.RepoMustNotBeArchived(), repo.MustBeNotEmpty, reqRepoCodeWriter, repo.SyncFork)
17441744
}, ignSignIn, context.RepoAssignment, context.UnitTypes())
17451745

1746-
m.Post("/{username}/{reponame}/lastcommit/*", ignSignIn, context.RepoAssignment, context.UnitTypes(), context.RepoRefByType(context.RepoRefCommit), reqRepoCodeReader, repo.LastCommit)
1746+
m.Get("/{username}/{reponame}/lastcommit/*", ignSignIn, context.RepoAssignment, context.UnitTypes(), context.RepoRefByType(context.RepoRefCommit), reqRepoCodeReader, repo.LastCommit)
17471747

17481748
m.Group("/{username}/{reponame}", func() {
17491749
if !setting.Repository.DisableStars {

templates/repo/view_list.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<table id="repo-files-table" class="ui single line table tw-mt-0" {{if .HasFilesWithoutLatestCommit}}hx-indicator="tr.notready td.message span" hx-trigger="load" hx-swap="morph" hx-post="{{.LastCommitLoaderURL}}"{{end}}>
1+
<table id="repo-files-table" class="ui single line table tw-mt-0" {{if .HasFilesWithoutLatestCommit}}hx-indicator="tr.notready td.message span" hx-trigger="load" hx-swap="morph" hx-get="{{.LastCommitLoaderURL}}"{{end}}>
22
<caption class="tw-sr-only">
33
{{ctx.Locale.Tr "repo.files.caption"}}
44
</caption>

tests/integration/repo_commit_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ func TestLastCommit(t *testing.T) {
8787
defer tests.PrepareTestEnv(t)()
8888

8989
t.Run("Anonymous", func(t *testing.T) {
90-
req := NewRequest(t, "POST", "/user2/repo1/lastcommit/65f1bf27bc3bf70f64657658635e66094edbcb4d")
90+
req := NewRequest(t, "GET", "/user2/repo1/lastcommit/65f1bf27bc3bf70f64657658635e66094edbcb4d")
9191
MakeRequest(t, req, http.StatusOK)
9292
})
9393

9494
t.Run("Signed in", func(t *testing.T) {
9595
session := loginUser(t, "user2")
9696

97-
req := NewRequest(t, "POST", "/user2/repo1/lastcommit/65f1bf27bc3bf70f64657658635e66094edbcb4d")
97+
req := NewRequest(t, "GET", "/user2/repo1/lastcommit/65f1bf27bc3bf70f64657658635e66094edbcb4d")
9898
session.MakeRequest(t, req, http.StatusOK)
9999
})
100100
}

0 commit comments

Comments
 (0)