mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-01-10 23:52:16 +01:00
Add support for diff and patch compare
This commit is contained in:
parent
4b69aa5c10
commit
5132854603
1 changed files with 20 additions and 0 deletions
|
@ -231,6 +231,10 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
|
|||
if infoPath == "" {
|
||||
infos = []string{baseRepo.DefaultBranch, baseRepo.DefaultBranch}
|
||||
} else {
|
||||
infoPath, isDiff := strings.CutSuffix(infoPath, ".diff")
|
||||
ctx.Data["DownloadDiff"] = isDiff
|
||||
infoPath, isPatch := strings.CutSuffix(infoPath, ".patch")
|
||||
ctx.Data["DownloadPatch"] = isPatch
|
||||
infos = strings.SplitN(infoPath, "...", 2)
|
||||
if len(infos) != 2 {
|
||||
if infos = strings.SplitN(infoPath, "..", 2); len(infos) == 2 {
|
||||
|
@ -717,6 +721,22 @@ func CompareDiff(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if ctx.Data["DownloadDiff"].(bool) {
|
||||
err := git.GetRepoRawDiffForFile(ci.HeadGitRepo, ci.BaseBranch, ci.HeadBranch,git.RawDiffNormal,"", ctx.Resp)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetDiff", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if ctx.Data["DownloadPatch"].(bool) {
|
||||
err := git.GetRepoRawDiffForFile(ci.HeadGitRepo, ci.BaseBranch, ci.HeadBranch,git.RawDiffPatch,"", ctx.Resp)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetPatch", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes
|
||||
ctx.Data["DirectComparison"] = ci.DirectComparison
|
||||
ctx.Data["OtherCompareSeparator"] = ".."
|
||||
|
|
Loading…
Reference in a new issue