|
|
@ -174,11 +174,11 @@ func GetPullRequest(ctx *context.APIContext) { |
|
|
|
ctx.JSON(http.StatusOK, convert.ToAPIPullRequest(pr)) |
|
|
|
ctx.JSON(http.StatusOK, convert.ToAPIPullRequest(pr)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// DownloadPullDiff render a pull's raw diff
|
|
|
|
// DownloadPullDiffOrPatch render a pull's raw diff or patch
|
|
|
|
func DownloadPullDiff(ctx *context.APIContext) { |
|
|
|
func DownloadPullDiffOrPatch(ctx *context.APIContext) { |
|
|
|
// swagger:operation GET /repos/{owner}/{repo}/pulls/{index}.diff repository repoDownloadPullDiff
|
|
|
|
// swagger:operation GET /repos/{owner}/{repo}/pulls/{index}.{diffType} repository repoDownloadPullDiffOrPatch
|
|
|
|
// ---
|
|
|
|
// ---
|
|
|
|
// summary: Get a pull request diff
|
|
|
|
// summary: Get a pull request diff or patch
|
|
|
|
// produces:
|
|
|
|
// produces:
|
|
|
|
// - text/plain
|
|
|
|
// - text/plain
|
|
|
|
// parameters:
|
|
|
|
// parameters:
|
|
|
@ -198,48 +198,17 @@ func DownloadPullDiff(ctx *context.APIContext) { |
|
|
|
// type: integer
|
|
|
|
// type: integer
|
|
|
|
// format: int64
|
|
|
|
// format: int64
|
|
|
|
// required: true
|
|
|
|
// required: true
|
|
|
|
// responses:
|
|
|
|
// - name: diffType
|
|
|
|
// "200":
|
|
|
|
|
|
|
|
// "$ref": "#/responses/string"
|
|
|
|
|
|
|
|
// "404":
|
|
|
|
|
|
|
|
// "$ref": "#/responses/notFound"
|
|
|
|
|
|
|
|
DownloadPullDiffOrPatch(ctx, false) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// DownloadPullPatch render a pull's raw patch
|
|
|
|
|
|
|
|
func DownloadPullPatch(ctx *context.APIContext) { |
|
|
|
|
|
|
|
// swagger:operation GET /repos/{owner}/{repo}/pulls/{index}.patch repository repoDownloadPullPatch
|
|
|
|
|
|
|
|
// ---
|
|
|
|
|
|
|
|
// summary: Get a pull request patch file
|
|
|
|
|
|
|
|
// produces:
|
|
|
|
|
|
|
|
// - text/plain
|
|
|
|
|
|
|
|
// parameters:
|
|
|
|
|
|
|
|
// - name: owner
|
|
|
|
|
|
|
|
// in: path
|
|
|
|
|
|
|
|
// description: owner of the repo
|
|
|
|
|
|
|
|
// type: string
|
|
|
|
|
|
|
|
// required: true
|
|
|
|
|
|
|
|
// - name: repo
|
|
|
|
|
|
|
|
// in: path
|
|
|
|
// in: path
|
|
|
|
// description: name of the repo
|
|
|
|
// description: whether the output is diff or patch
|
|
|
|
// type: string
|
|
|
|
// type: string
|
|
|
|
// required: true
|
|
|
|
// enum: [diff, patch]
|
|
|
|
// - name: index
|
|
|
|
|
|
|
|
// in: path
|
|
|
|
|
|
|
|
// description: index of the pull request to get
|
|
|
|
|
|
|
|
// type: integer
|
|
|
|
|
|
|
|
// format: int64
|
|
|
|
|
|
|
|
// required: true
|
|
|
|
// required: true
|
|
|
|
// responses:
|
|
|
|
// responses:
|
|
|
|
// "200":
|
|
|
|
// "200":
|
|
|
|
// "$ref": "#/responses/string"
|
|
|
|
// "$ref": "#/responses/string"
|
|
|
|
// "404":
|
|
|
|
// "404":
|
|
|
|
// "$ref": "#/responses/notFound"
|
|
|
|
// "$ref": "#/responses/notFound"
|
|
|
|
DownloadPullDiffOrPatch(ctx, true) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// DownloadPullDiffOrPatch render a pull's raw diff or patch
|
|
|
|
|
|
|
|
func DownloadPullDiffOrPatch(ctx *context.APIContext, patch bool) { |
|
|
|
|
|
|
|
pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) |
|
|
|
pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
if models.IsErrPullRequestNotExist(err) { |
|
|
|
if models.IsErrPullRequestNotExist(err) { |
|
|
@ -249,6 +218,12 @@ func DownloadPullDiffOrPatch(ctx *context.APIContext, patch bool) { |
|
|
|
} |
|
|
|
} |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var patch bool |
|
|
|
|
|
|
|
if ctx.Params(":diffType") == "diff" { |
|
|
|
|
|
|
|
patch = false |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
patch = true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if err := pull_service.DownloadDiffOrPatch(pr, ctx, patch); err != nil { |
|
|
|
if err := pull_service.DownloadDiffOrPatch(pr, ctx, patch); err != nil { |
|
|
|
ctx.InternalServerError(err) |
|
|
|
ctx.InternalServerError(err) |
|
|
|