Adjust error reporting from merge failures and use LC_ALL=C for git (#8548)

There are two major components to this PR:

* This PR handles merge and rebase failures from merging a little more nicely with Flash errors rather a 500.
* All git commands are run in the LC_ALL="C" environment to ensure that error messages are in English. This DefaultLocale is defined in a way that if necessary (due to platform weirdness) it can be overridden at build time using LDFLAGS="-X "code.gitea.io/gitea/modules/git.DefaultLocale=C"" with C changed for the locale as necessary.
This commit is contained in:
zeripath 2019-11-10 08:42:51 +00:00 committed by GitHub
parent 31416a5f4e
commit 8eeb2877d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 483 additions and 95 deletions

View file

@ -626,6 +626,18 @@ func MergePullRequest(ctx *context.APIContext, form auth.MergePullRequestForm) {
if models.IsErrInvalidMergeStyle(err) {
ctx.Status(405)
return
} else if models.IsErrMergeConflicts(err) {
conflictError := err.(models.ErrMergeConflicts)
ctx.JSON(http.StatusConflict, conflictError)
} else if models.IsErrRebaseConflicts(err) {
conflictError := err.(models.ErrRebaseConflicts)
ctx.JSON(http.StatusConflict, conflictError)
} else if models.IsErrMergeUnrelatedHistories(err) {
conflictError := err.(models.ErrMergeUnrelatedHistories)
ctx.JSON(http.StatusConflict, conflictError)
} else if models.IsErrMergePushOutOfDate(err) {
ctx.Status(http.StatusConflict)
return
}
ctx.Error(500, "Merge", err)
return