aboutsummaryrefslogtreecommitdiffstats
path: root/formats/packp/ulreq/ulreq.go
diff options
context:
space:
mode:
authorAlberto Cortés <alcortesm@gmail.com>2016-11-02 10:14:15 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2016-11-02 09:14:15 +0000
commit1918bfe458729488e4a656cbbef7a2430e7ec2f5 (patch)
treed130d025584f3db0f781028db8978bb0a6a227ef /formats/packp/ulreq/ulreq.go
parent6b7464a22c6177d9e0cf96e1aaaae13c127c3149 (diff)
downloadgo-git-1918bfe458729488e4a656cbbef7a2430e7ec2f5.tar.gz
ulreq: adds encoder and decoder for upload-request messages (#106)
* ulreq: adds encoder and decoder for upload-request messages * ulreq: stop using _test suffix for testing package names (@mcuadros comment)
Diffstat (limited to 'formats/packp/ulreq/ulreq.go')
-rw-r--r--formats/packp/ulreq/ulreq.go56
1 files changed, 56 insertions, 0 deletions
diff --git a/formats/packp/ulreq/ulreq.go b/formats/packp/ulreq/ulreq.go
new file mode 100644
index 0000000..e47450a
--- /dev/null
+++ b/formats/packp/ulreq/ulreq.go
@@ -0,0 +1,56 @@
+// Package ulreq implements encoding and decoding upload-request
+// messages from a git-upload-pack command.
+package ulreq
+
+import (
+ "time"
+
+ "gopkg.in/src-d/go-git.v4/core"
+ "gopkg.in/src-d/go-git.v4/formats/packp"
+)
+
+// UlReq values represent the information transmitted on a
+// upload-request message. Values from this type are not zero-value
+// safe, use the New function instead.
+type UlReq struct {
+ Capabilities *packp.Capabilities
+ Wants []core.Hash
+ Shallows []core.Hash
+ Depth Depth
+}
+
+// Depth values stores the desired depth of the requested packfile: see
+// DepthCommit, DepthSince and DepthReference.
+type Depth interface {
+ isDepth()
+}
+
+// DepthCommits values stores the maximum number of requested commits in
+// the packfile. Zero means infinite. A negative value will have
+// undefined consecuences.
+type DepthCommits int
+
+func (d DepthCommits) isDepth() {}
+
+// DepthSince values requests only commits newer than the specified time.
+type DepthSince time.Time
+
+func (d DepthSince) isDepth() {}
+
+// DepthReference requests only commits not to found in the specified reference.
+type DepthReference string
+
+func (d DepthReference) isDepth() {}
+
+// New returns a pointer to a new UlReq value, ready to be used. It has
+// no capabilities, wants or shallows and an infinite depth. Please
+// note that to encode an upload-request it has to have at least one
+// wanted hash.
+func New() *UlReq {
+ return &UlReq{
+ Capabilities: packp.NewCapabilities(),
+ Wants: []core.Hash{},
+ Shallows: []core.Hash{},
+ Depth: DepthCommits(0),
+ }
+}