mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 21:28:11 +09:00 
			
		
		
		
	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:
		| @@ -1206,6 +1206,79 @@ func (err ErrInvalidMergeStyle) Error() string { | ||||
| 		err.ID, err.Style) | ||||
| } | ||||
|  | ||||
| // ErrMergeConflicts represents an error if merging fails with a conflict | ||||
| type ErrMergeConflicts struct { | ||||
| 	Style  MergeStyle | ||||
| 	StdOut string | ||||
| 	StdErr string | ||||
| 	Err    error | ||||
| } | ||||
|  | ||||
| // IsErrMergeConflicts checks if an error is a ErrMergeConflicts. | ||||
| func IsErrMergeConflicts(err error) bool { | ||||
| 	_, ok := err.(ErrMergeConflicts) | ||||
| 	return ok | ||||
| } | ||||
|  | ||||
| func (err ErrMergeConflicts) Error() string { | ||||
| 	return fmt.Sprintf("Merge Conflict Error: %v: %s\n%s", err.Err, err.StdErr, err.StdOut) | ||||
| } | ||||
|  | ||||
| // ErrMergeUnrelatedHistories represents an error if merging fails due to unrelated histories | ||||
| type ErrMergeUnrelatedHistories struct { | ||||
| 	Style  MergeStyle | ||||
| 	StdOut string | ||||
| 	StdErr string | ||||
| 	Err    error | ||||
| } | ||||
|  | ||||
| // IsErrMergeUnrelatedHistories checks if an error is a ErrMergeUnrelatedHistories. | ||||
| func IsErrMergeUnrelatedHistories(err error) bool { | ||||
| 	_, ok := err.(ErrMergeUnrelatedHistories) | ||||
| 	return ok | ||||
| } | ||||
|  | ||||
| func (err ErrMergeUnrelatedHistories) Error() string { | ||||
| 	return fmt.Sprintf("Merge UnrelatedHistories Error: %v: %s\n%s", err.Err, err.StdErr, err.StdOut) | ||||
| } | ||||
|  | ||||
| // ErrMergePushOutOfDate represents an error if merging fails due to unrelated histories | ||||
| type ErrMergePushOutOfDate struct { | ||||
| 	Style  MergeStyle | ||||
| 	StdOut string | ||||
| 	StdErr string | ||||
| 	Err    error | ||||
| } | ||||
|  | ||||
| // IsErrMergePushOutOfDate checks if an error is a ErrMergePushOutOfDate. | ||||
| func IsErrMergePushOutOfDate(err error) bool { | ||||
| 	_, ok := err.(ErrMergePushOutOfDate) | ||||
| 	return ok | ||||
| } | ||||
|  | ||||
| func (err ErrMergePushOutOfDate) Error() string { | ||||
| 	return fmt.Sprintf("Merge PushOutOfDate Error: %v: %s\n%s", err.Err, err.StdErr, err.StdOut) | ||||
| } | ||||
|  | ||||
| // ErrRebaseConflicts represents an error if rebase fails with a conflict | ||||
| type ErrRebaseConflicts struct { | ||||
| 	Style     MergeStyle | ||||
| 	CommitSHA string | ||||
| 	StdOut    string | ||||
| 	StdErr    string | ||||
| 	Err       error | ||||
| } | ||||
|  | ||||
| // IsErrRebaseConflicts checks if an error is a ErrRebaseConflicts. | ||||
| func IsErrRebaseConflicts(err error) bool { | ||||
| 	_, ok := err.(ErrRebaseConflicts) | ||||
| 	return ok | ||||
| } | ||||
|  | ||||
| func (err ErrRebaseConflicts) Error() string { | ||||
| 	return fmt.Sprintf("Rebase Error: %v: Whilst Rebasing: %s\n%s\n%s", err.Err, err.CommitSHA, err.StdErr, err.StdOut) | ||||
| } | ||||
|  | ||||
| // _________                                       __ | ||||
| // \_   ___ \  ____   _____   _____   ____   _____/  |_ | ||||
| // /    \  \/ /  _ \ /     \ /     \_/ __ \ /    \   __\ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user