diff options
author | Runxi Yu <me@runxiyu.org> | 2025-04-06 01:55:21 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-04-06 02:08:58 +0800 |
commit | faa5ca8fab23176d390e9522f1485d467851545b (patch) | |
tree | d3b1d081e0ea5e7f71a94dc1d301e2540a8abcc8 /internal/unsorted/http_handle_repo_log.go | |
parent | Slight refactor on NewServer (diff) | |
download | forge-0.1.28.tar.gz forge-0.1.28.tar.zst forge-0.1.28.zip |
Move stuff into internal/unsortedv0.1.28
Diffstat (limited to 'internal/unsorted/http_handle_repo_log.go')
-rw-r--r-- | internal/unsorted/http_handle_repo_log.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/internal/unsorted/http_handle_repo_log.go b/internal/unsorted/http_handle_repo_log.go new file mode 100644 index 0000000..c25c60b --- /dev/null +++ b/internal/unsorted/http_handle_repo_log.go @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: AGPL-3.0-only +// SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> + +package unsorted + +import ( + "net/http" + + "github.com/go-git/go-git/v5" + "github.com/go-git/go-git/v5/plumbing" + "go.lindenii.runxiyu.org/forge/internal/web" +) + +// httpHandleRepoLog provides a page with a complete Git log. +// +// TODO: This currently provides all commits in the branch. It should be +// paginated and cached instead. +func (s *Server) httpHandleRepoLog(writer http.ResponseWriter, _ *http.Request, params map[string]any) { + var repo *git.Repository + var refHash plumbing.Hash + var err error + + repo = params["repo"].(*git.Repository) + + if refHash, err = getRefHash(repo, params["ref_type"].(string), params["ref_name"].(string)); err != nil { + web.ErrorPage500(s.templates, writer, params, "Error getting ref hash: "+err.Error()) + return + } + + logOptions := git.LogOptions{From: refHash} //exhaustruct:ignore + commitIter, err := repo.Log(&logOptions) + if err != nil { + web.ErrorPage500(s.templates, writer, params, "Error getting recent commits: "+err.Error()) + return + } + params["commits"], params["commits_err"] = commitIterSeqErr(commitIter) + + s.renderTemplate(writer, "repo_log", params) +} |