mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-01-25 21:57:01 +01:00
Improve code
This commit is contained in:
parent
11a433ed1c
commit
10067db6b0
1 changed files with 7 additions and 4 deletions
|
@ -233,8 +233,11 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
|
||||||
} else {
|
} else {
|
||||||
infoPath, isDiff := strings.CutSuffix(infoPath, ".diff")
|
infoPath, isDiff := strings.CutSuffix(infoPath, ".diff")
|
||||||
ctx.Data["ComparingDiff"] = isDiff
|
ctx.Data["ComparingDiff"] = isDiff
|
||||||
infoPath, isPatch := strings.CutSuffix(infoPath, ".patch")
|
if !isDiff {
|
||||||
ctx.Data["ComparingPatch"] = isPatch
|
var isPatch bool
|
||||||
|
infoPath, isPatch = strings.CutSuffix(infoPath, ".patch")
|
||||||
|
ctx.Data["ComparingPatch"] = isPatch
|
||||||
|
}
|
||||||
infos = strings.SplitN(infoPath, "...", 2)
|
infos = strings.SplitN(infoPath, "...", 2)
|
||||||
if len(infos) != 2 {
|
if len(infos) != 2 {
|
||||||
if infos = strings.SplitN(infoPath, "..", 2); len(infos) == 2 {
|
if infos = strings.SplitN(infoPath, "..", 2); len(infos) == 2 {
|
||||||
|
@ -721,7 +724,7 @@ func CompareDiff(ctx *context.Context) {
|
||||||
return
|
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)
|
err := git.GetRepoRawDiffForFile(ci.HeadGitRepo, ci.BaseBranch, ci.HeadBranch, git.RawDiffNormal, "", ctx.Resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.ServerError("ComparingDiff", err)
|
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)
|
err := git.GetRepoRawDiffForFile(ci.HeadGitRepo, ci.BaseBranch, ci.HeadBranch, git.RawDiffPatch, "", ctx.Resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.ServerError("ComparingPatch", err)
|
ctx.ServerError("ComparingPatch", err)
|
||||||
|
|
Loading…
Reference in a new issue