summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authormirko <mirko@owlcode.it>2025-01-01 08:07:33 +0100
committermirko <mirko@owlcode.it>2025-01-01 08:08:12 +0100
commit10067db6b03cd75d4f771bacdbb70ad54c8ae08c (patch)
treeb16cc3a99bb0837ef0dfc719da0a414a0b904927 /routers
parentFix tests (diff)
downloadforgejo-10067db6b03cd75d4f771bacdbb70ad54c8ae08c.tar.xz
forgejo-10067db6b03cd75d4f771bacdbb70ad54c8ae08c.zip
Improve code
Diffstat (limited to 'routers')
-rw-r--r--routers/web/repo/compare.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go
index bd13cf4ed9..24785d867e 100644
--- a/routers/web/repo/compare.go
+++ b/routers/web/repo/compare.go
@@ -233,8 +233,11 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
} else {
infoPath, isDiff := strings.CutSuffix(infoPath, ".diff")
ctx.Data["ComparingDiff"] = isDiff
- infoPath, isPatch := strings.CutSuffix(infoPath, ".patch")
- ctx.Data["ComparingPatch"] = isPatch
+ if !isDiff {
+ var isPatch bool
+ infoPath, isPatch = strings.CutSuffix(infoPath, ".patch")
+ ctx.Data["ComparingPatch"] = isPatch
+ }
infos = strings.SplitN(infoPath, "...", 2)
if len(infos) != 2 {
if infos = strings.SplitN(infoPath, "..", 2); len(infos) == 2 {
@@ -721,7 +724,7 @@ func CompareDiff(ctx *context.Context) {
return
}
- if ctx.Data["ComparingDiff"].(bool) {
+ if ctx.Data["ComparingDiff"] != nil && ctx.Data["ComparingDiff"].(bool) {
err := git.GetRepoRawDiffForFile(ci.HeadGitRepo, ci.BaseBranch, ci.HeadBranch, git.RawDiffNormal, "", ctx.Resp)
if err != nil {
ctx.ServerError("ComparingDiff", err)
@@ -729,7 +732,7 @@ func CompareDiff(ctx *context.Context) {
}
}
- if ctx.Data["ComparingPatch"].(bool) {
+ if ctx.Data["ComparingPatch"] != nil && ctx.Data["ComparingPatch"].(bool) {
err := git.GetRepoRawDiffForFile(ci.HeadGitRepo, ci.BaseBranch, ci.HeadBranch, git.RawDiffPatch, "", ctx.Resp)
if err != nil {
ctx.ServerError("ComparingPatch", err)