diff options
author | Santiago M. Mola <santi@mola.io> | 2016-12-16 19:31:01 +0100 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-12-16 19:31:01 +0100 |
commit | b3adbed0ce15d82bf41d23cc507c5dd47a6c4260 (patch) | |
tree | 156ce904ed4af15d89a85876e3585e4c55204ae8 /options.go | |
parent | 950676c36030a8796c0a69a8aae606ff1f448b03 (diff) | |
download | go-git-b3adbed0ce15d82bf41d23cc507c5dd47a6c4260.tar.gz |
remote: make Fetch atomic. (#185)
* Remote now exposes only Fetch. No Connect, Disconnect, etc.
* Repository uses a private fetch method in Remote for Clone/Pull.
* getting capabilities, HEAD or other information from remote
requires using the lower level client.
* add Fetch method to Repository.
Diffstat (limited to 'options.go')
-rw-r--r-- | options.go | 20 |
1 files changed, 13 insertions, 7 deletions
@@ -51,19 +51,19 @@ func (o *CloneOptions) Validate() error { return nil } -// PullOptions describe how a pull should be perform +// PullOptions describe how a pull should be perform. type PullOptions struct { - // Name of the remote to be pulled + // Name of the remote to be pulled. If empty, uses the default. RemoteName string - // Remote branch to clone + // Remote branch to clone. If empty, uses HEAD. ReferenceName plumbing.ReferenceName - // Fetch only ReferenceName if true + // Fetch only ReferenceName if true. SingleBranch bool - // Limit fetching to the specified number of commits + // Limit fetching to the specified number of commits. Depth int } -// Validate validate the fields and set the default values +// Validate validate the fields and set the default values. func (o *PullOptions) Validate() error { if o.RemoteName == "" { o.RemoteName = DefaultRemoteName @@ -78,7 +78,9 @@ func (o *PullOptions) Validate() error { // FetchOptions describe how a fetch should be perform type FetchOptions struct { - RefSpecs []config.RefSpec + // Name of the remote to fetch from. Defaults to origin. + RemoteName string + RefSpecs []config.RefSpec // Depth limit fetching to the specified number of commits from the tip of // each remote branch history. Depth int @@ -86,6 +88,10 @@ type FetchOptions struct { // Validate validate the fields and set the default values func (o *FetchOptions) Validate() error { + if o.RemoteName == "" { + o.RemoteName = DefaultRemoteName + } + for _, r := range o.RefSpecs { if !r.IsValid() { return ErrInvalidRefSpec |