aboutsummaryrefslogtreecommitdiff
path: root/http_handle_repo_commit.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-04-05 23:59:17 +0800
committerRunxi Yu <me@runxiyu.org>2025-04-05 23:59:17 +0800
commit0c0062b22ff4ddac9cf8c4ef84116eddba99bce2 (patch)
tree2d1790cdf42b0dcdb3f82f77cea2b86fb7a42120 /http_handle_repo_commit.go
parentscfg: Remove tests for now (diff)
downloadforge-0c0062b22ff4ddac9cf8c4ef84116eddba99bce2.tar.gz
forge-0c0062b22ff4ddac9cf8c4ef84116eddba99bce2.tar.zst
forge-0c0062b22ff4ddac9cf8c4ef84116eddba99bce2.zip
templates shall no longer be a global variable
Diffstat (limited to 'http_handle_repo_commit.go')
-rw-r--r--http_handle_repo_commit.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/http_handle_repo_commit.go b/http_handle_repo_commit.go
index c348dca..196489f 100644
--- a/http_handle_repo_commit.go
+++ b/http_handle_repo_commit.go
@@ -32,7 +32,7 @@ type usableChunk struct {
Content string
}
-func httpHandleRepoCommit(writer http.ResponseWriter, request *http.Request, params map[string]any) {
+func (s *Server) httpHandleRepoCommit(writer http.ResponseWriter, request *http.Request, params map[string]any) {
var repo *git.Repository
var commitIDStrSpec, commitIDStrSpecNoSuffix string
var commitID plumbing.Hash
@@ -47,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 {
- web.ErrorPage500(templates, writer, params, "Error getting commit object: "+err.Error())
+ web.ErrorPage500(s.templates, writer, params, "Error getting commit object: "+err.Error())
return
}
if commitIDStrSpecNoSuffix != commitIDStrSpec {
var patchStr string
if patchStr, err = fmtCommitPatch(commitObj); err != nil {
- web.ErrorPage500(templates, writer, params, "Error formatting patch: "+err.Error())
+ web.ErrorPage500(s.templates, writer, params, "Error formatting patch: "+err.Error())
return
}
fmt.Fprintln(writer, patchStr)
@@ -71,7 +71,7 @@ func httpHandleRepoCommit(writer http.ResponseWriter, request *http.Request, par
parentCommitHash, patch, err = commitToPatch(commitObj)
if err != nil {
- web.ErrorPage500(templates, writer, params, "Error getting patch from commit: "+err.Error())
+ web.ErrorPage500(s.templates, writer, params, "Error getting patch from commit: "+err.Error())
return
}
params["parent_commit_hash"] = parentCommitHash.String()
@@ -79,7 +79,7 @@ func httpHandleRepoCommit(writer http.ResponseWriter, request *http.Request, par
params["file_patches"] = makeUsableFilePatches(patch)
- renderTemplate(writer, "repo_commit", params)
+ s.renderTemplate(writer, "repo_commit", params)
}
type fakeDiffFile struct {