|
9 | 9 |
|
10 | 10 | "github.com/go-git/go-billy/v5/osfs"
|
11 | 11 | "github.com/go-git/go-git/v5/config"
|
| 12 | + "github.com/go-git/go-git/v5/internal/url" |
12 | 13 | "github.com/go-git/go-git/v5/plumbing"
|
13 | 14 | "github.com/go-git/go-git/v5/plumbing/cache"
|
14 | 15 | "github.com/go-git/go-git/v5/plumbing/format/packfile"
|
@@ -103,7 +104,11 @@ func (r *Remote) PushContext(ctx context.Context, o *PushOptions) (err error) {
|
103 | 104 | return fmt.Errorf("remote names don't match: %s != %s", o.RemoteName, r.c.Name)
|
104 | 105 | }
|
105 | 106 |
|
106 |
| - s, err := newSendPackSession(r.c.URLs[0], o.Auth, o.InsecureSkipTLS, o.CABundle) |
| 107 | + if o.RemoteURL == "" { |
| 108 | + o.RemoteURL = r.c.URLs[0] |
| 109 | + } |
| 110 | + |
| 111 | + s, err := newSendPackSession(o.RemoteURL, o.Auth, o.InsecureSkipTLS, o.CABundle) |
107 | 112 | if err != nil {
|
108 | 113 | return err
|
109 | 114 | }
|
@@ -183,12 +188,12 @@ func (r *Remote) PushContext(ctx context.Context, o *PushOptions) (err error) {
|
183 | 188 | var hashesToPush []plumbing.Hash
|
184 | 189 | // Avoid the expensive revlist operation if we're only doing deletes.
|
185 | 190 | if !allDelete {
|
186 |
| - if r.c.IsFirstURLLocal() { |
| 191 | + if url.IsLocalEndpoint(o.RemoteURL) { |
187 | 192 | // If we're are pushing to a local repo, it might be much
|
188 | 193 | // faster to use a local storage layer to get the commits
|
189 | 194 | // to ignore, when calculating the object revlist.
|
190 | 195 | localStorer := filesystem.NewStorage(
|
191 |
| - osfs.New(r.c.URLs[0]), cache.NewObjectLRUDefault()) |
| 196 | + osfs.New(o.RemoteURL), cache.NewObjectLRUDefault()) |
192 | 197 | hashesToPush, err = revlist.ObjectsWithStorageForIgnores(
|
193 | 198 | r.s, localStorer, objects, haves)
|
194 | 199 | } else {
|
@@ -314,7 +319,11 @@ func (r *Remote) fetch(ctx context.Context, o *FetchOptions) (sto storer.Referen
|
314 | 319 | o.RefSpecs = r.c.Fetch
|
315 | 320 | }
|
316 | 321 |
|
317 |
| - s, err := newUploadPackSession(r.c.URLs[0], o.Auth, o.InsecureSkipTLS, o.CABundle) |
| 322 | + if o.RemoteURL == "" { |
| 323 | + o.RemoteURL = r.c.URLs[0] |
| 324 | + } |
| 325 | + |
| 326 | + s, err := newUploadPackSession(o.RemoteURL, o.Auth, o.InsecureSkipTLS, o.CABundle) |
318 | 327 | if err != nil {
|
319 | 328 | return nil, err
|
320 | 329 | }
|
|
0 commit comments