Преглед изворни кода

Remove 'non-fast-forward update' from the known non-errors

Brendan Abolivier пре 6 година
родитељ
комит
d53ea113fd
Signed by: Brendan Abolivier <contact@brendanabolivier.com> GPG key ID: 8EF1500759F70623
1 измењених фајлова са 5 додато и 11 уклоњено
  1. 5
    11
      src/git/git.go

+ 5
- 11
src/git/git.go Прегледај датотеку

@@ -84,9 +84,8 @@ func clone(repo string, clonePath string, auth *gitssh.PublicKeys) (*gogit.Repos
84 84
 // remote using a given auth, in order to be up to date with the remote.
85 85
 // Returns with the go-git representation of the repository.
86 86
 // Returns an error if there was an issue opening the repo, getting its work
87
-// tree or pulling from the remote. In the latter case, if the error is "already
88
-// up to date", "non-fast-forward update" or "remote repository is empty",
89
-// doesn't return any error.
87
+// tree or pulling from the remote. In the latter case, if the error is a known
88
+// non-error, doesn't return any error.
90 89
 func pull(clonePath string, auth *gitssh.PublicKeys) (*gogit.Repository, error) {
91 90
 	// Open the repository
92 91
 	r, err := gogit.PlainOpen(clonePath)
@@ -134,8 +133,7 @@ func dirExists(path string) (bool, error) {
134 133
 // created from the configuration to authenticate on the remote.
135 134
 // Returns with an error if there was an issue creating the authentication
136 135
 // structure instance or pushing to the remote. In the latter case, if the error
137
-// is "already up to date", "non-fast-forward update" or "remote repository is
138
-// empty", doesn't return any error.
136
+// is a known non-error, doesn't return any error.
139 137
 func Push(r *gogit.Repository, cfg config.GitSettings) error {
140 138
 	// Get the authentication structure instance
141 139
 	auth, err := getAuth(cfg.User, cfg.PrivateKeyPath)
@@ -166,6 +164,8 @@ func Push(r *gogit.Repository, cfg config.GitSettings) error {
166 164
 // processRemoteErrors checks an error against known non-errors returned when
167 165
 // communicating with the remote. If the error is a non-error, returns nil and
168 166
 // logs it with the provided fields. If not, returns the error.
167
+// Current known non-errors are "already up to date" and "remote repository is
168
+// empty".
169 169
 func checkRemoteErrors(err error, logFields logrus.Fields) error {
170 170
 	var nonError bool
171 171
 
@@ -182,12 +182,6 @@ func checkRemoteErrors(err error, logFields logrus.Fields) error {
182 182
 		break
183 183
 	}
184 184
 
185
-	// go-git doesn't have an error variable for "non-fast-forward update", so
186
-	// this is the only way to detect it
187
-	if strings.HasPrefix(err.Error(), "non-fast-forward update") {
188
-		nonError = true
189
-	}
190
-
191 185
 	// Log non-error
192 186
 	if nonError {
193 187
 		logrus.WithFields(logFields).Warn("Caught specific non-error")