mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-18 19:32:55 +02:00
parse .raw and .diff optional compare parameters
This commit is contained in:
parent
bfa2d101c4
commit
f86ddd53f0
@ -685,7 +685,6 @@ func CommonRoutes() *web.Router {
|
|||||||
// https://github.com/opencontainers/distribution-spec/blob/main/spec.md
|
// https://github.com/opencontainers/distribution-spec/blob/main/spec.md
|
||||||
func ContainerRoutes() *web.Router {
|
func ContainerRoutes() *web.Router {
|
||||||
r := web.NewRouter()
|
r := web.NewRouter()
|
||||||
|
|
||||||
r.Use(context.PackageContexter())
|
r.Use(context.PackageContexter())
|
||||||
|
|
||||||
verifyAuth(r, []auth.Method{
|
verifyAuth(r, []auth.Method{
|
||||||
|
@ -18,4 +18,5 @@ type CompareInfo struct {
|
|||||||
BaseBranch string
|
BaseBranch string
|
||||||
HeadBranch string
|
HeadBranch string
|
||||||
DirectComparison bool
|
DirectComparison bool
|
||||||
|
RawDiffType git.RawDiffType
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,19 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
|
|||||||
)
|
)
|
||||||
|
|
||||||
infoPath = ctx.PathParam("*")
|
infoPath = ctx.PathParam("*")
|
||||||
|
|
||||||
var infos []string
|
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 == "" {
|
if infoPath == "" {
|
||||||
infos = []string{baseRepo.DefaultBranch, baseRepo.DefaultBranch}
|
infos = []string{baseRepo.DefaultBranch, baseRepo.DefaultBranch}
|
||||||
} else {
|
} else {
|
||||||
@ -743,6 +755,12 @@ func CompareDiff(ctx *context.Context) {
|
|||||||
return
|
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)
|
baseTags, err := repo_model.GetTagNamesByRepoID(ctx, ctx.Repo.Repository.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.ServerError("GetTagNamesByRepoID", err)
|
ctx.ServerError("GetTagNamesByRepoID", err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user