MCPcopy Create free account
hub / github.com/go-git/go-git / Encode

Method Encode

plumbing/protocol/packp/updreq_encode.go:13–43  ·  view source on GitHub ↗

Encode writes the ReferenceUpdateRequest encoding to the stream.

(w io.Writer)

Source from the content-addressed store, hash-verified

11
12// Encode writes the ReferenceUpdateRequest encoding to the stream.
13func (req *ReferenceUpdateRequest) Encode(w io.Writer) error {
14 if err := req.validate(); err != nil {
15 return err
16 }
17
18 e := pktline.NewEncoder(w)
19
20 if err := req.encodeShallow(e, req.Shallow); err != nil {
21 return err
22 }
23
24 if err := req.encodeCommands(e, req.Commands, req.Capabilities); err != nil {
25 return err
26 }
27
28 if req.Capabilities.Supports(capability.PushOptions) {
29 if err := req.encodeOptions(e, req.Options); err != nil {
30 return err
31 }
32 }
33
34 if req.Packfile != nil {
35 if _, err := io.Copy(w, req.Packfile); err != nil {
36 return err
37 }
38
39 return req.Packfile.Close()
40 }
41
42 return nil
43}
44
45func (req *ReferenceUpdateRequest) encodeShallow(e *pktline.Encoder,
46 h *plumbing.Hash) error {

Callers 1

TestZeroValueMethod · 0.95

Calls 7

validateMethod · 0.95
encodeShallowMethod · 0.95
encodeCommandsMethod · 0.95
encodeOptionsMethod · 0.95
NewEncoderFunction · 0.92
SupportsMethod · 0.80
CloseMethod · 0.65

Tested by 1

TestZeroValueMethod · 0.76