From 4dddeae12d3af854bb7afba4653f64db2f0e772f Mon Sep 17 00:00:00 2001 From: Arya Kiran Date: Sun, 23 Jul 2023 13:16:39 +0530 Subject: [PATCH] add diff file download --- serve/serve.go | 9 +++++++++ views/commit.html | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/serve/serve.go b/serve/serve.go index af7eea7..d2091ef 100644 --- a/serve/serve.go +++ b/serve/serve.go @@ -140,6 +140,15 @@ func Serve(port string) { }) app.Get("/:user/:repo", pages.HandleRepo) app.Get("/:user/:repo/commit/:commit", pages.HandleCommit) + app.Get("/diff/:user/:repo/commit/:commit", func(c *fiber.Ctx) error { + if proxying == "true" { + utils.ProxyRequest(c, "https://github.com/"+c.Params("user")+"/"+c.Params("repo")+"/commit/"+c.Params("commit")+".diff") + return nil + } else { + c.Redirect("https://github.com/" + c.Params("user") + "/" + c.Params("repo") + "/commit/" + c.Params("commit") + ".diff") + return nil + } + }) app.Get("/:user/:repo/info/+", func(c *fiber.Ctx) error { // This is needed but it looks like git doesn't send it. Or maybe i just shouldn't program at midnight param := "?service=git-upload-pack" diff --git a/views/commit.html b/views/commit.html index 9b88fbe..f58f614 100644 --- a/views/commit.html +++ b/views/commit.html @@ -19,7 +19,7 @@

{{.CommitHashShortened}} | {{.CommitName}}

Raw