mirror of
https://github.com/go-gitea/gitea.git
synced 2025-05-14 02:58:12 +00:00
parse .raw and .diff optional compare parameters
This commit is contained in:
parent
a3c29538f1
commit
ed52100a1a
@ -685,7 +685,6 @@ func CommonRoutes() *web.Router {
|
||||
// https://github.com/opencontainers/distribution-spec/blob/main/spec.md
|
||||
func ContainerRoutes() *web.Router {
|
||||
r := web.NewRouter()
|
||||
|
||||
r.Use(context.PackageContexter())
|
||||
|
||||
verifyAuth(r, []auth.Method{
|
||||
|
@ -18,4 +18,5 @@ type CompareInfo struct {
|
||||
BaseBranch string
|
||||
HeadBranch string
|
||||
DirectComparison bool
|
||||
RawDiffType git.RawDiffType
|
||||
}
|
||||
|
@ -228,7 +228,19 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
|
||||
)
|
||||
|
||||
infoPath = ctx.PathParam("*")
|
||||
|
||||
var infos []string
|
||||
|
||||
// Handle possible suffixes: .diff or .patch
|
||||
if strings.HasSuffix(infoPath, ".diff") {
|
||||
ci.RawDiffType = git.RawDiffNormal
|
||||
infoPath = strings.TrimSuffix(infoPath, ".diff")
|
||||
|
||||
} else if strings.HasSuffix(infoPath, ".patch") {
|
||||
ci.RawDiffType = git.RawDiffPatch
|
||||
infoPath = strings.TrimSuffix(infoPath, ".patch")
|
||||
}
|
||||
|
||||
if infoPath == "" {
|
||||
infos = []string{baseRepo.DefaultBranch, baseRepo.DefaultBranch}
|
||||
} else {
|
||||
@ -743,6 +755,12 @@ func CompareDiff(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if ci.RawDiffType != "" {
|
||||
git.GetRepoRawDiffForFile(ci.HeadGitRepo, ci.BaseBranch, ci.HeadBranch, ci.RawDiffType, "", ctx.Resp)
|
||||
ctx.Resp.Flush()
|
||||
return
|
||||
}
|
||||
|
||||
baseTags, err := repo_model.GetTagNamesByRepoID(ctx, ctx.Repo.Repository.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetTagNamesByRepoID", err)
|
||||
|
Loading…
Reference in New Issue
Block a user