aboutsummaryrefslogtreecommitdiffstats
path: root/options.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-08-22 00:18:02 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-08-22 00:18:02 +0200
commitf42d82364c5d159f65a48e720433ad2bc97f0b7f (patch)
tree82623f4163625786f4e8e41028dcd1c7abaf209f /options.go
parenta045606fc9c5cbf30b409384cbdad4804f01c61d (diff)
downloadgo-git-f42d82364c5d159f65a48e720433ad2bc97f0b7f.tar.gz
Remote.Fetch multiple RefSpec support
Diffstat (limited to 'options.go')
-rw-r--r--options.go31
1 files changed, 7 insertions, 24 deletions
diff --git a/options.go b/options.go
index 414b7f0..3691a6f 100644
--- a/options.go
+++ b/options.go
@@ -2,7 +2,6 @@ package git
import (
"errors"
- "fmt"
"gopkg.in/src-d/go-git.v3/clients/common"
"gopkg.in/src-d/go-git.v4/config"
@@ -11,9 +10,7 @@ import (
const (
// DefaultRemoteName name of the default Remote, just like git command
- DefaultRemoteName = "origin"
- DefaultSingleBranchRefSpec = "+refs/heads/%s:refs/remotes/%s/%[1]s"
- DefaultRefSpec = "+refs/heads/*:refs/remotes/%s/*"
+ DefaultRemoteName = "origin"
)
var (
@@ -54,22 +51,6 @@ func (o *RepositoryCloneOptions) Validate() error {
return nil
}
-func (o *RepositoryCloneOptions) refSpec(s core.ReferenceStorage) (config.RefSpec, error) {
- var spec string
- if o.SingleBranch {
- head, err := core.ResolveReference(s, o.ReferenceName)
- if err != nil {
- return "", err
- }
-
- spec = fmt.Sprintf(DefaultSingleBranchRefSpec, head.Name().Short(), o.RemoteName)
- } else {
- spec = fmt.Sprintf(DefaultRefSpec, o.RemoteName)
- }
-
- return config.RefSpec(spec), nil
-}
-
// RepositoryPullOptions describe how a pull should be perform
type RepositoryPullOptions struct {
// Name of the remote to be pulled
@@ -97,14 +78,16 @@ func (o *RepositoryPullOptions) Validate() error {
// RemoteFetchOptions describe how a fetch should be perform
type RemoteFetchOptions struct {
- RefSpec config.RefSpec
- Depth int
+ RefSpecs []config.RefSpec
+ Depth int
}
// Validate validate the fields and set the default values
func (o *RemoteFetchOptions) Validate() error {
- if !o.RefSpec.IsValid() {
- return ErrInvalidRefSpec
+ for _, r := range o.RefSpecs {
+ if !r.IsValid() {
+ return ErrInvalidRefSpec
+ }
}
return nil