|
@@ -135,23 +135,29 @@ func dirExists(path string) (bool, error) {
|
135
|
135
|
// structure instance or pushing to the remote. In the latter case, if the error
|
136
|
136
|
// is "already up to date" or "non-fast-forward update", doesn't return any error.
|
137
|
137
|
func Push(r *gogit.Repository, cfg config.GitSettings) error {
|
|
138
|
+ // Get the authentication structure instance
|
138
|
139
|
auth, err := getAuth(cfg.User, cfg.PrivateKeyPath)
|
139
|
140
|
if err != nil {
|
140
|
141
|
return err
|
141
|
142
|
}
|
142
|
143
|
|
|
144
|
+ // Push to remote
|
143
|
145
|
err = r.Push(&gogit.PushOptions{
|
144
|
146
|
Auth: auth,
|
145
|
147
|
})
|
146
|
148
|
|
147
|
|
- if err == gogit.NoErrAlreadyUpToDate {
|
148
|
|
- return nil
|
149
|
|
- }
|
|
149
|
+ // Don't return with an error for "already up to date" or "non-fast-forward
|
|
150
|
+ // update"
|
|
151
|
+ if err != nil {
|
|
152
|
+ if err == gogit.NoErrAlreadyUpToDate {
|
|
153
|
+ return nil
|
|
154
|
+ }
|
150
|
155
|
|
151
|
|
- // go-git doesn't have an error variable for "non-fast-forward update", so
|
152
|
|
- // this is the only way to detect it
|
153
|
|
- if strings.HasPrefix(err.Error(), "non-fast-forward update") {
|
154
|
|
- return nil
|
|
156
|
+ // go-git doesn't have an error variable for "non-fast-forward update", so
|
|
157
|
+ // this is the only way to detect it
|
|
158
|
+ if strings.HasPrefix(err.Error(), "non-fast-forward update") {
|
|
159
|
+ return nil
|
|
160
|
+ }
|
155
|
161
|
}
|
156
|
162
|
|
157
|
163
|
return err
|