Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit b3adbed

Browse files
smolamcuadros
authored andcommitted
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.
1 parent 950676c commit b3adbed

File tree

5 files changed

+283
-273
lines changed

5 files changed

+283
-273
lines changed

options.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,19 @@ func (o *CloneOptions) Validate() error {
5151
return nil
5252
}
5353

54-
// PullOptions describe how a pull should be perform
54+
// PullOptions describe how a pull should be perform.
5555
type PullOptions struct {
56-
// Name of the remote to be pulled
56+
// Name of the remote to be pulled. If empty, uses the default.
5757
RemoteName string
58-
// Remote branch to clone
58+
// Remote branch to clone. If empty, uses HEAD.
5959
ReferenceName plumbing.ReferenceName
60-
// Fetch only ReferenceName if true
60+
// Fetch only ReferenceName if true.
6161
SingleBranch bool
62-
// Limit fetching to the specified number of commits
62+
// Limit fetching to the specified number of commits.
6363
Depth int
6464
}
6565

66-
// Validate validate the fields and set the default values
66+
// Validate validate the fields and set the default values.
6767
func (o *PullOptions) Validate() error {
6868
if o.RemoteName == "" {
6969
o.RemoteName = DefaultRemoteName
@@ -78,14 +78,20 @@ func (o *PullOptions) Validate() error {
7878

7979
// FetchOptions describe how a fetch should be perform
8080
type FetchOptions struct {
81-
RefSpecs []config.RefSpec
81+
// Name of the remote to fetch from. Defaults to origin.
82+
RemoteName string
83+
RefSpecs []config.RefSpec
8284
// Depth limit fetching to the specified number of commits from the tip of
8385
// each remote branch history.
8486
Depth int
8587
}
8688

8789
// Validate validate the fields and set the default values
8890
func (o *FetchOptions) Validate() error {
91+
if o.RemoteName == "" {
92+
o.RemoteName = DefaultRemoteName
93+
}
94+
8995
for _, r := range o.RefSpecs {
9096
if !r.IsValid() {
9197
return ErrInvalidRefSpec

0 commit comments

Comments
 (0)