aboutsummaryrefslogtreecommitdiff
path: root/http_handle_repo_commit.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-04-05 23:18:30 +0800
committerRunxi Yu <me@runxiyu.org>2025-04-05 23:18:30 +0800
commitedc30e6d36b51f73d2db31e6fbc55f86e8ca451f (patch)
tree5d15da4dc72b71e86f7293e51d12b29706e8889a /http_handle_repo_commit.go
parentRemove an unnecessary nolint:gochecknoglobals (diff)
downloadforge-edc30e6d36b51f73d2db31e6fbc55f86e8ca451f.tar.gz
forge-edc30e6d36b51f73d2db31e6fbc55f86e8ca451f.tar.zst
forge-edc30e6d36b51f73d2db31e6fbc55f86e8ca451f.zip
web: Separate HTTP error pages into its own package
Diffstat (limited to 'http_handle_repo_commit.go')
-rw-r--r--http_handle_repo_commit.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/http_handle_repo_commit.go b/http_handle_repo_commit.go
index 1042aff..c348dca 100644
--- a/http_handle_repo_commit.go
+++ b/http_handle_repo_commit.go
@@ -14,6 +14,7 @@ import (
"github.com/go-git/go-git/v5/plumbing/format/diff"
"github.com/go-git/go-git/v5/plumbing/object"
"go.lindenii.runxiyu.org/forge/internal/misc"
+ "go.lindenii.runxiyu.org/forge/internal/web"
)
// usableFilePatch is a [diff.FilePatch] that is structured in a way more
@@ -46,13 +47,13 @@ func httpHandleRepoCommit(writer http.ResponseWriter, request *http.Request, par
commitIDStrSpecNoSuffix = strings.TrimSuffix(commitIDStrSpec, ".patch")
commitID = plumbing.NewHash(commitIDStrSpecNoSuffix)
if commitObj, err = repo.CommitObject(commitID); err != nil {
- errorPage500(writer, params, "Error getting commit object: "+err.Error())
+ web.ErrorPage500(templates, writer, params, "Error getting commit object: "+err.Error())
return
}
if commitIDStrSpecNoSuffix != commitIDStrSpec {
var patchStr string
if patchStr, err = fmtCommitPatch(commitObj); err != nil {
- errorPage500(writer, params, "Error formatting patch: "+err.Error())
+ web.ErrorPage500(templates, writer, params, "Error formatting patch: "+err.Error())
return
}
fmt.Fprintln(writer, patchStr)
@@ -70,7 +71,7 @@ func httpHandleRepoCommit(writer http.ResponseWriter, request *http.Request, par
parentCommitHash, patch, err = commitToPatch(commitObj)
if err != nil {
- errorPage500(writer, params, "Error getting patch from commit: "+err.Error())
+ web.ErrorPage500(templates, writer, params, "Error getting patch from commit: "+err.Error())
return
}
params["parent_commit_hash"] = parentCommitHash.String()