aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/protocol/packp/updreq_encode.go
diff options
context:
space:
mode:
authorSören Bohn <soeren.bohn@ppro.com>2021-10-26 15:49:15 +0200
committerSören Bohn <soeren@lambda-complex.org>2021-10-26 16:08:54 +0200
commite729edb00d36e9bd19f99dfa493984233b0dccfa (patch)
tree3cb555f90071aa32768c6a49a90d52d47eda64be /plumbing/protocol/packp/updreq_encode.go
parent99457e570d34320b12fb4fcd0f054f3d0b1d3eec (diff)
downloadgo-git-e729edb00d36e9bd19f99dfa493984233b0dccfa.tar.gz
plumbing: packp, Add encoding for push-options. Fixes #268.
go-git: Add field `Options` to `PushOptions`, wire functionality.
Diffstat (limited to 'plumbing/protocol/packp/updreq_encode.go')
-rw-r--r--plumbing/protocol/packp/updreq_encode.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/plumbing/protocol/packp/updreq_encode.go b/plumbing/protocol/packp/updreq_encode.go
index 2545e93..08a819e 100644
--- a/plumbing/protocol/packp/updreq_encode.go
+++ b/plumbing/protocol/packp/updreq_encode.go
@@ -29,6 +29,12 @@ func (req *ReferenceUpdateRequest) Encode(w io.Writer) error {
return err
}
+ if req.Capabilities.Supports(capability.PushOptions) {
+ if err := req.encodeOptions(e, req.Options); err != nil {
+ return err
+ }
+ }
+
if req.Packfile != nil {
if _, err := io.Copy(w, req.Packfile); err != nil {
return err
@@ -73,3 +79,15 @@ func formatCommand(cmd *Command) string {
n := cmd.New.String()
return fmt.Sprintf("%s %s %s", o, n, cmd.Name)
}
+
+func (req *ReferenceUpdateRequest) encodeOptions(e *pktline.Encoder,
+ opts []*Option) error {
+
+ for _, opt := range opts {
+ if err := e.Encodef("%s=%s", opt.Key, opt.Value); err != nil {
+ return err
+ }
+ }
+
+ return e.Flush()
+}