summaryrefslogtreecommitdiffstats
path: root/modules/git
diff options
context:
space:
mode:
Diffstat (limited to 'modules/git')
-rw-r--r--modules/git/error.go17
-rw-r--r--modules/git/repo.go7
2 files changed, 24 insertions, 0 deletions
diff --git a/modules/git/error.go b/modules/git/error.go
index 85a938a7da..387dd724e5 100644
--- a/modules/git/error.go
+++ b/modules/git/error.go
@@ -159,3 +159,20 @@ func (err *ErrPushRejected) GenerateMessage() {
}
err.Message = strings.TrimSpace(messageBuilder.String())
}
+
+// ErrMoreThanOne represents an error if pull request fails when there are more than one sources (branch, tag) with the same name
+type ErrMoreThanOne struct {
+ StdOut string
+ StdErr string
+ Err error
+}
+
+// IsErrMoreThanOne checks if an error is a ErrMoreThanOne
+func IsErrMoreThanOne(err error) bool {
+ _, ok := err.(*ErrMoreThanOne)
+ return ok
+}
+
+func (err *ErrMoreThanOne) Error() string {
+ return fmt.Sprintf("ErrMoreThanOne Error: %v: %s\n%s", err.Err, err.StdErr, err.StdOut)
+}
diff --git a/modules/git/repo.go b/modules/git/repo.go
index e06cd43935..43f329f448 100644
--- a/modules/git/repo.go
+++ b/modules/git/repo.go
@@ -225,6 +225,13 @@ func Push(repoPath string, opts PushOptions) error {
}
err.GenerateMessage()
return err
+ } else if strings.Contains(errbuf.String(), "matches more than one") {
+ err := &ErrMoreThanOne{
+ StdOut: outbuf.String(),
+ StdErr: errbuf.String(),
+ Err: err,
+ }
+ return err
}
}