diff options
author | Ori Rawlings <orirawlings@gmail.com> | 2017-08-23 21:37:49 -0500 |
---|---|---|
committer | Ori Rawlings <orirawlings@gmail.com> | 2017-09-01 09:17:23 -0500 |
commit | 76efca13092ba245caf15f232f467e68fa1f73ed (patch) | |
tree | e94ed3536e5af8d9201e83de9a7011ab5ac37dad /remote.go | |
parent | 3ca370277427c5d508f0dedacbd559523a305121 (diff) | |
download | go-git-76efca13092ba245caf15f232f467e68fa1f73ed.tar.gz |
Add sideband support for push
Diffstat (limited to 'remote.go')
-rw-r--r-- | remote.go | 25 |
1 files changed, 21 insertions, 4 deletions
@@ -65,7 +65,6 @@ func (r *Remote) Push(o *PushOptions) error { // operation is complete, an error is returned. The context only affects to the // transport operations. func (r *Remote) PushContext(ctx context.Context, o *PushOptions) error { - // TODO: Sideband support if err := o.Validate(); err != nil { return err } @@ -108,9 +107,8 @@ func (r *Remote) PushContext(ctx context.Context, o *PushOptions) error { return ErrDeleteRefNotSupported } - req := packp.NewReferenceUpdateRequestFromCapabilities(ar.Capabilities) - if err := r.addReferencesToUpdate(o.RefSpecs, remoteRefs, req); err != nil { - + req, err := r.newReferenceUpdateRequest(o, remoteRefs, ar) + if err != nil { return err } @@ -158,6 +156,25 @@ func (r *Remote) PushContext(ctx context.Context, o *PushOptions) error { return r.updateRemoteReferenceStorage(req, rs) } +func (r *Remote) newReferenceUpdateRequest(o *PushOptions, remoteRefs storer.ReferenceStorer, ar *packp.AdvRefs) (*packp.ReferenceUpdateRequest, error) { + req := packp.NewReferenceUpdateRequestFromCapabilities(ar.Capabilities) + + if o.Progress != nil { + req.Progress = o.Progress + if ar.Capabilities.Supports(capability.Sideband64k) { + req.Capabilities.Set(capability.Sideband64k) + } else if ar.Capabilities.Supports(capability.Sideband) { + req.Capabilities.Set(capability.Sideband) + } + } + + if err := r.addReferencesToUpdate(o.RefSpecs, remoteRefs, req); err != nil { + return nil, err + } + + return req, nil +} + func (r *Remote) updateRemoteReferenceStorage( req *packp.ReferenceUpdateRequest, result *packp.ReportStatus, |