aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--_examples/remotes/main.go2
-rw-r--r--config/config.go23
-rw-r--r--config/config_test.go27
-rw-r--r--example_test.go2
-rw-r--r--remote.go11
-rw-r--r--remote_test.go55
-rw-r--r--repository.go2
-rw-r--r--repository_test.go14
-rw-r--r--storage/filesystem/config_test.go6
-rw-r--r--storage/test/storage_suite.go2
-rw-r--r--submodule.go2
-rw-r--r--worktree_test.go8
12 files changed, 93 insertions, 61 deletions
diff --git a/_examples/remotes/main.go b/_examples/remotes/main.go
index 90817dc..7cae8bb 100644
--- a/_examples/remotes/main.go
+++ b/_examples/remotes/main.go
@@ -27,7 +27,7 @@ func main() {
Info("git remote add example https://github.com/git-fixtures/basic.git")
_, err = r.CreateRemote(&config.RemoteConfig{
Name: "example",
- URL: "https://github.com/git-fixtures/basic.git",
+ URLs: []string{"https://github.com/git-fixtures/basic.git"},
})
CheckIfError(err)
diff --git a/config/config.go b/config/config.go
index bcea63e..1f3cd77 100644
--- a/config/config.go
+++ b/config/config.go
@@ -187,8 +187,9 @@ func (c *Config) marshalSubmodules() {
type RemoteConfig struct {
// Name of the remote
Name string
- // URL the URL of a remote repository
- URL string
+ // URLs the URLs of a remote repository. It must be non-empty. Fetch will
+ // always use the first URL, while push will use all of them.
+ URLs []string
// Fetch the default set of "refspec" for fetch operation
Fetch []RefSpec
@@ -203,7 +204,7 @@ func (c *RemoteConfig) Validate() error {
return ErrRemoteConfigEmptyName
}
- if c.URL == "" {
+ if len(c.URLs) == 0 {
return ErrRemoteConfigEmptyURL
}
@@ -233,8 +234,13 @@ func (c *RemoteConfig) unmarshal(s *format.Subsection) error {
fetch = append(fetch, rs)
}
+ var urls []string
+ for _, f := range c.raw.Options.GetAll(urlKey) {
+ urls = append(urls, f)
+ }
+
c.Name = c.raw.Name
- c.URL = c.raw.Option(urlKey)
+ c.URLs = urls
c.Fetch = fetch
return nil
@@ -246,9 +252,14 @@ func (c *RemoteConfig) marshal() *format.Subsection {
}
c.raw.Name = c.Name
- c.raw.SetOption(urlKey, c.URL)
+ c.raw.RemoveOption(urlKey)
+ for _, url := range c.URLs {
+ c.raw.AddOption(urlKey, url)
+ }
+
+ c.raw.RemoveOption(fetchKey)
for _, rs := range c.Fetch {
- c.raw.SetOption(fetchKey, rs.String())
+ c.raw.AddOption(fetchKey, rs.String())
}
return c.raw
diff --git a/config/config_test.go b/config/config_test.go
index cfab36d..e958677 100644
--- a/config/config_test.go
+++ b/config/config_test.go
@@ -13,6 +13,11 @@ func (s *ConfigSuite) TestUnmarshall(c *C) {
[remote "origin"]
url = git@github.com:mcuadros/go-git.git
fetch = +refs/heads/*:refs/remotes/origin/*
+[remote "alt"]
+ url = git@github.com:mcuadros/go-git.git
+ url = git@github.com:src-d/go-git.git
+ fetch = +refs/heads/*:refs/remotes/origin/*
+ fetch = +refs/pull/*:refs/remotes/origin/pull/*
[submodule "qux"]
path = qux
url = https://github.com/foo/qux.git
@@ -28,10 +33,13 @@ func (s *ConfigSuite) TestUnmarshall(c *C) {
c.Assert(cfg.Core.IsBare, Equals, true)
c.Assert(cfg.Core.Worktree, Equals, "foo")
- c.Assert(cfg.Remotes, HasLen, 1)
+ c.Assert(cfg.Remotes, HasLen, 2)
c.Assert(cfg.Remotes["origin"].Name, Equals, "origin")
- c.Assert(cfg.Remotes["origin"].URL, Equals, "git@github.com:mcuadros/go-git.git")
+ c.Assert(cfg.Remotes["origin"].URLs, DeepEquals, []string{"git@github.com:mcuadros/go-git.git"})
c.Assert(cfg.Remotes["origin"].Fetch, DeepEquals, []RefSpec{"+refs/heads/*:refs/remotes/origin/*"})
+ c.Assert(cfg.Remotes["alt"].Name, Equals, "alt")
+ c.Assert(cfg.Remotes["alt"].URLs, DeepEquals, []string{"git@github.com:mcuadros/go-git.git", "git@github.com:src-d/go-git.git"})
+ c.Assert(cfg.Remotes["alt"].Fetch, DeepEquals, []RefSpec{"+refs/heads/*:refs/remotes/origin/*", "+refs/pull/*:refs/remotes/origin/pull/*"})
c.Assert(cfg.Submodules, HasLen, 1)
c.Assert(cfg.Submodules["qux"].Name, Equals, "qux")
c.Assert(cfg.Submodules["qux"].URL, Equals, "https://github.com/foo/qux.git")
@@ -45,6 +53,11 @@ func (s *ConfigSuite) TestMarshall(c *C) {
worktree = bar
[remote "origin"]
url = git@github.com:mcuadros/go-git.git
+[remote "alt"]
+ url = git@github.com:mcuadros/go-git.git
+ url = git@github.com:src-d/go-git.git
+ fetch = +refs/heads/*:refs/remotes/origin/*
+ fetch = +refs/pull/*:refs/remotes/origin/pull/*
[submodule "qux"]
url = https://github.com/foo/qux.git
`)
@@ -54,7 +67,13 @@ func (s *ConfigSuite) TestMarshall(c *C) {
cfg.Core.Worktree = "bar"
cfg.Remotes["origin"] = &RemoteConfig{
Name: "origin",
- URL: "git@github.com:mcuadros/go-git.git",
+ URLs: []string{"git@github.com:mcuadros/go-git.git"},
+ }
+
+ cfg.Remotes["alt"] = &RemoteConfig{
+ Name: "alt",
+ URLs: []string{"git@github.com:mcuadros/go-git.git", "git@github.com:src-d/go-git.git"},
+ Fetch: []RefSpec{"+refs/heads/*:refs/remotes/origin/*", "+refs/pull/*:refs/remotes/origin/pull/*"},
}
cfg.Submodules["qux"] = &Submodule{
@@ -122,7 +141,7 @@ func (s *ConfigSuite) TestRemoteConfigValidateMissingName(c *C) {
}
func (s *ConfigSuite) TestRemoteConfigValidateDefault(c *C) {
- config := &RemoteConfig{Name: "foo", URL: "http://foo/bar"}
+ config := &RemoteConfig{Name: "foo", URLs: []string{"http://foo/bar"}}
c.Assert(config.Validate(), IsNil)
fetch := config.Fetch
diff --git a/example_test.go b/example_test.go
index 585b38a..1b369ba 100644
--- a/example_test.go
+++ b/example_test.go
@@ -91,7 +91,7 @@ func ExampleRepository_CreateRemote() {
// Add a new remote, with the default fetch refspec
_, err := r.CreateRemote(&config.RemoteConfig{
Name: "example",
- URL: "https://github.com/git-fixtures/basic.git",
+ URLs: []string{"https://github.com/git-fixtures/basic.git"},
})
if err != nil {
diff --git a/remote.go b/remote.go
index fe44009..eb5a6a2 100644
--- a/remote.go
+++ b/remote.go
@@ -43,8 +43,11 @@ func (r *Remote) Config() *config.RemoteConfig {
}
func (r *Remote) String() string {
- fetch := r.c.URL
- push := r.c.URL
+ var fetch, push string
+ if len(r.c.URLs) > 0 {
+ fetch = r.c.URLs[0]
+ push = r.c.URLs[0]
+ }
return fmt.Sprintf("%s\t%s (fetch)\n%[1]s\t%[3]s (push)", r.c.Name, fetch, push)
}
@@ -71,7 +74,7 @@ func (r *Remote) PushContext(ctx context.Context, o *PushOptions) error {
return fmt.Errorf("remote names don't match: %s != %s", o.RemoteName, r.c.Name)
}
- s, err := newSendPackSession(r.c.URL, o.Auth)
+ s, err := newSendPackSession(r.c.URLs[0], o.Auth)
if err != nil {
return err
}
@@ -211,7 +214,7 @@ func (r *Remote) fetch(ctx context.Context, o *FetchOptions) (storer.ReferenceSt
o.RefSpecs = r.c.Fetch
}
- s, err := newUploadPackSession(r.c.URL, o.Auth)
+ s, err := newUploadPackSession(r.c.URLs[0], o.Auth)
if err != nil {
return nil, err
}
diff --git a/remote_test.go b/remote_test.go
index ece052a..4953b12 100644
--- a/remote_test.go
+++ b/remote_test.go
@@ -26,25 +26,25 @@ type RemoteSuite struct {
var _ = Suite(&RemoteSuite{})
func (s *RemoteSuite) TestFetchInvalidEndpoint(c *C) {
- r := newRemote(nil, &config.RemoteConfig{Name: "foo", URL: "http://\\"})
+ r := newRemote(nil, &config.RemoteConfig{Name: "foo", URLs: []string{"http://\\"}})
err := r.Fetch(&FetchOptions{RemoteName: "foo"})
c.Assert(err, ErrorMatches, ".*invalid character.*")
}
func (s *RemoteSuite) TestFetchNonExistentEndpoint(c *C) {
- r := newRemote(nil, &config.RemoteConfig{Name: "foo", URL: "ssh://non-existent/foo.git"})
+ r := newRemote(nil, &config.RemoteConfig{Name: "foo", URLs: []string{"ssh://non-existent/foo.git"}})
err := r.Fetch(&FetchOptions{})
c.Assert(err, NotNil)
}
func (s *RemoteSuite) TestFetchInvalidSchemaEndpoint(c *C) {
- r := newRemote(nil, &config.RemoteConfig{Name: "foo", URL: "qux://foo"})
+ r := newRemote(nil, &config.RemoteConfig{Name: "foo", URLs: []string{"qux://foo"}})
err := r.Fetch(&FetchOptions{})
c.Assert(err, ErrorMatches, ".*unsupported scheme.*")
}
func (s *RemoteSuite) TestFetchInvalidFetchOptions(c *C) {
- r := newRemote(nil, &config.RemoteConfig{Name: "foo", URL: "qux://foo"})
+ r := newRemote(nil, &config.RemoteConfig{Name: "foo", URLs: []string{"qux://foo"}})
invalid := config.RefSpec("^*$ñ")
err := r.Fetch(&FetchOptions{RefSpecs: []config.RefSpec{invalid}})
c.Assert(err, Equals, config.ErrRefSpecMalformedSeparator)
@@ -52,7 +52,7 @@ func (s *RemoteSuite) TestFetchInvalidFetchOptions(c *C) {
func (s *RemoteSuite) TestFetchWildcard(c *C) {
r := newRemote(memory.NewStorage(), &config.RemoteConfig{
- URL: s.GetBasicLocalRepositoryURL(),
+ URLs: []string{s.GetBasicLocalRepositoryURL()},
})
s.testFetch(c, r, &FetchOptions{
@@ -68,7 +68,7 @@ func (s *RemoteSuite) TestFetchWildcard(c *C) {
func (s *RemoteSuite) TestFetchWildcardTags(c *C) {
r := newRemote(memory.NewStorage(), &config.RemoteConfig{
- URL: s.GetLocalRepositoryURL(fixtures.ByTag("tags").One()),
+ URLs: []string{s.GetLocalRepositoryURL(fixtures.ByTag("tags").One())},
})
s.testFetch(c, r, &FetchOptions{
@@ -87,7 +87,7 @@ func (s *RemoteSuite) TestFetchWildcardTags(c *C) {
func (s *RemoteSuite) TestFetch(c *C) {
r := newRemote(memory.NewStorage(), &config.RemoteConfig{
- URL: s.GetLocalRepositoryURL(fixtures.ByTag("tags").One()),
+ URLs: []string{s.GetLocalRepositoryURL(fixtures.ByTag("tags").One())},
})
s.testFetch(c, r, &FetchOptions{
@@ -101,7 +101,7 @@ func (s *RemoteSuite) TestFetch(c *C) {
func (s *RemoteSuite) TestFetchContext(c *C) {
r := newRemote(memory.NewStorage(), &config.RemoteConfig{
- URL: s.GetLocalRepositoryURL(fixtures.ByTag("tags").One()),
+ URLs: []string{s.GetLocalRepositoryURL(fixtures.ByTag("tags").One())},
})
ctx, cancel := context.WithCancel(context.Background())
@@ -113,12 +113,11 @@ func (s *RemoteSuite) TestFetchContext(c *C) {
},
})
c.Assert(err, NotNil)
-
}
func (s *RemoteSuite) TestFetchWithAllTags(c *C) {
r := newRemote(memory.NewStorage(), &config.RemoteConfig{
- URL: s.GetLocalRepositoryURL(fixtures.ByTag("tags").One()),
+ URLs: []string{s.GetLocalRepositoryURL(fixtures.ByTag("tags").One())},
})
s.testFetch(c, r, &FetchOptions{
@@ -138,7 +137,7 @@ func (s *RemoteSuite) TestFetchWithAllTags(c *C) {
func (s *RemoteSuite) TestFetchWithNoTags(c *C) {
r := newRemote(memory.NewStorage(), &config.RemoteConfig{
- URL: s.GetLocalRepositoryURL(fixtures.ByTag("tags").One()),
+ URLs: []string{s.GetLocalRepositoryURL(fixtures.ByTag("tags").One())},
})
s.testFetch(c, r, &FetchOptions{
@@ -154,7 +153,7 @@ func (s *RemoteSuite) TestFetchWithNoTags(c *C) {
func (s *RemoteSuite) TestFetchWithDepth(c *C) {
r := newRemote(memory.NewStorage(), &config.RemoteConfig{
- URL: s.GetBasicLocalRepositoryURL(),
+ URLs: []string{s.GetBasicLocalRepositoryURL()},
})
s.testFetch(c, r, &FetchOptions{
@@ -193,7 +192,7 @@ func (s *RemoteSuite) TestFetchWithProgress(c *C) {
sto := memory.NewStorage()
buf := bytes.NewBuffer(nil)
- r := newRemote(sto, &config.RemoteConfig{Name: "foo", URL: url})
+ r := newRemote(sto, &config.RemoteConfig{Name: "foo", URLs: []string{url}})
refspec := config.RefSpec("+refs/heads/*:refs/remotes/origin/*")
err := r.Fetch(&FetchOptions{
@@ -229,7 +228,7 @@ func (s *RemoteSuite) TestFetchWithPackfileWriter(c *C) {
mock := &mockPackfileWriter{Storer: fss}
url := s.GetBasicLocalRepositoryURL()
- r := newRemote(mock, &config.RemoteConfig{Name: "foo", URL: url})
+ r := newRemote(mock, &config.RemoteConfig{Name: "foo", URLs: []string{url}})
refspec := config.RefSpec("+refs/heads/*:refs/remotes/origin/*")
err = r.Fetch(&FetchOptions{
@@ -258,7 +257,7 @@ func (s *RemoteSuite) TestFetchNoErrAlreadyUpToDate(c *C) {
func (s *RemoteSuite) TestFetchNoErrAlreadyUpToDateButStillUpdateLocalRemoteRefs(c *C) {
r := newRemote(memory.NewStorage(), &config.RemoteConfig{
- URL: s.GetBasicLocalRepositoryURL(),
+ URLs: []string{s.GetBasicLocalRepositoryURL()},
})
o := &FetchOptions{
@@ -294,7 +293,7 @@ func (s *RemoteSuite) TestFetchNoErrAlreadyUpToDateWithNonCommitObjects(c *C) {
}
func (s *RemoteSuite) doTestFetchNoErrAlreadyUpToDate(c *C, url string) {
- r := newRemote(memory.NewStorage(), &config.RemoteConfig{URL: url})
+ r := newRemote(memory.NewStorage(), &config.RemoteConfig{URLs: []string{url}})
o := &FetchOptions{
RefSpecs: []config.RefSpec{
@@ -311,7 +310,7 @@ func (s *RemoteSuite) doTestFetchNoErrAlreadyUpToDate(c *C, url string) {
func (s *RemoteSuite) TestString(c *C) {
r := newRemote(nil, &config.RemoteConfig{
Name: "foo",
- URL: "https://github.com/git-fixtures/basic.git",
+ URLs: []string{"https://github.com/git-fixtures/basic.git"},
})
c.Assert(r.String(), Equals, ""+
@@ -331,7 +330,7 @@ func (s *RemoteSuite) TestPushToEmptyRepository(c *C) {
r := newRemote(sto, &config.RemoteConfig{
Name: DefaultRemoteName,
- URL: url,
+ URLs: []string{url},
})
rs := config.RefSpec("refs/heads/*:refs/heads/*")
@@ -369,7 +368,7 @@ func (s *RemoteSuite) TestPushContext(c *C) {
r := newRemote(sto, &config.RemoteConfig{
Name: DefaultRemoteName,
- URL: url,
+ URLs: []string{url},
})
ctx, cancel := context.WithCancel(context.Background())
@@ -392,7 +391,7 @@ func (s *RemoteSuite) TestPushTags(c *C) {
r := newRemote(sto, &config.RemoteConfig{
Name: DefaultRemoteName,
- URL: url,
+ URLs: []string{url},
})
err = r.Push(&PushOptions{
@@ -416,7 +415,7 @@ func (s *RemoteSuite) TestPushNoErrAlreadyUpToDate(c *C) {
r := newRemote(sto, &config.RemoteConfig{
Name: DefaultRemoteName,
- URL: fs.Root(),
+ URLs: []string{fs.Root()},
})
err = r.Push(&PushOptions{
@@ -490,7 +489,7 @@ func (s *RemoteSuite) TestPushForce(c *C) {
url := dstFs.Root()
r := newRemote(sto, &config.RemoteConfig{
Name: DefaultRemoteName,
- URL: url,
+ URLs: []string{url},
})
oldRef, err := dstSto.Reference(plumbing.ReferenceName("refs/heads/branch"))
@@ -540,25 +539,25 @@ func (s *RemoteSuite) TestPushNewReference(c *C) {
}
func (s *RemoteSuite) TestPushInvalidEndpoint(c *C) {
- r := newRemote(nil, &config.RemoteConfig{Name: "foo", URL: "http://\\"})
+ r := newRemote(nil, &config.RemoteConfig{Name: "foo", URLs: []string{"http://\\"}})
err := r.Push(&PushOptions{RemoteName: "foo"})
c.Assert(err, ErrorMatches, ".*invalid character.*")
}
func (s *RemoteSuite) TestPushNonExistentEndpoint(c *C) {
- r := newRemote(nil, &config.RemoteConfig{Name: "foo", URL: "ssh://non-existent/foo.git"})
+ r := newRemote(nil, &config.RemoteConfig{Name: "foo", URLs: []string{"ssh://non-existent/foo.git"}})
err := r.Push(&PushOptions{})
c.Assert(err, NotNil)
}
func (s *RemoteSuite) TestPushInvalidSchemaEndpoint(c *C) {
- r := newRemote(nil, &config.RemoteConfig{Name: "origin", URL: "qux://foo"})
+ r := newRemote(nil, &config.RemoteConfig{Name: "origin", URLs: []string{"qux://foo"}})
err := r.Push(&PushOptions{})
c.Assert(err, ErrorMatches, ".*unsupported scheme.*")
}
func (s *RemoteSuite) TestPushInvalidFetchOptions(c *C) {
- r := newRemote(nil, &config.RemoteConfig{Name: "foo", URL: "qux://foo"})
+ r := newRemote(nil, &config.RemoteConfig{Name: "foo", URLs: []string{"qux://foo"}})
invalid := config.RefSpec("^*$ñ")
err := r.Push(&PushOptions{RefSpecs: []config.RefSpec{invalid}})
c.Assert(err, Equals, config.ErrRefSpecMalformedSeparator)
@@ -567,7 +566,7 @@ func (s *RemoteSuite) TestPushInvalidFetchOptions(c *C) {
func (s *RemoteSuite) TestPushInvalidRefSpec(c *C) {
r := newRemote(nil, &config.RemoteConfig{
Name: DefaultRemoteName,
- URL: "some-url",
+ URLs: []string{"some-url"},
})
rs := config.RefSpec("^*$**")
@@ -580,7 +579,7 @@ func (s *RemoteSuite) TestPushInvalidRefSpec(c *C) {
func (s *RemoteSuite) TestPushWrongRemoteName(c *C) {
r := newRemote(nil, &config.RemoteConfig{
Name: DefaultRemoteName,
- URL: "some-url",
+ URLs: []string{"some-url"},
})
err := r.Push(&PushOptions{
diff --git a/repository.go b/repository.go
index 00ffaf7..50109f7 100644
--- a/repository.go
+++ b/repository.go
@@ -408,7 +408,7 @@ func (r *Repository) clone(ctx context.Context, o *CloneOptions) error {
c := &config.RemoteConfig{
Name: o.RemoteName,
- URL: o.URL,
+ URLs: []string{o.URL},
}
if _, err := r.CreateRemote(c); err != nil {
diff --git a/repository_test.go b/repository_test.go
index 558149b..00ce120 100644
--- a/repository_test.go
+++ b/repository_test.go
@@ -181,7 +181,7 @@ func (s *RepositorySuite) TestCreateRemoteAndRemote(c *C) {
r, _ := Init(memory.NewStorage(), nil)
remote, err := r.CreateRemote(&config.RemoteConfig{
Name: "foo",
- URL: "http://foo/foo.git",
+ URLs: []string{"http://foo/foo.git"},
})
c.Assert(err, IsNil)
@@ -205,7 +205,7 @@ func (s *RepositorySuite) TestDeleteRemote(c *C) {
r, _ := Init(memory.NewStorage(), nil)
_, err := r.CreateRemote(&config.RemoteConfig{
Name: "foo",
- URL: "http://foo/foo.git",
+ URLs: []string{"http://foo/foo.git"},
})
c.Assert(err, IsNil)
@@ -426,7 +426,7 @@ func (s *RepositorySuite) TestFetch(c *C) {
r, _ := Init(memory.NewStorage(), nil)
_, err := r.CreateRemote(&config.RemoteConfig{
Name: DefaultRemoteName,
- URL: s.GetBasicLocalRepositoryURL(),
+ URLs: []string{s.GetBasicLocalRepositoryURL()},
})
c.Assert(err, IsNil)
c.Assert(r.Fetch(&FetchOptions{}), IsNil)
@@ -449,7 +449,7 @@ func (s *RepositorySuite) TestFetchContext(c *C) {
r, _ := Init(memory.NewStorage(), nil)
_, err := r.CreateRemote(&config.RemoteConfig{
Name: DefaultRemoteName,
- URL: s.GetBasicLocalRepositoryURL(),
+ URLs: []string{s.GetBasicLocalRepositoryURL()},
})
c.Assert(err, IsNil)
@@ -531,7 +531,7 @@ func (s *RepositorySuite) TestCloneConfig(c *C) {
c.Assert(cfg.Core.IsBare, Equals, true)
c.Assert(cfg.Remotes, HasLen, 1)
c.Assert(cfg.Remotes["origin"].Name, Equals, "origin")
- c.Assert(cfg.Remotes["origin"].URL, Not(Equals), "")
+ c.Assert(cfg.Remotes["origin"].URLs, HasLen, 1)
}
func (s *RepositorySuite) TestCloneSingleBranchAndNonHEAD(c *C) {
@@ -629,7 +629,7 @@ func (s *RepositorySuite) TestPush(c *C) {
_, err = s.Repository.CreateRemote(&config.RemoteConfig{
Name: "test",
- URL: url,
+ URLs: []string{url},
})
c.Assert(err, IsNil)
@@ -657,7 +657,7 @@ func (s *RepositorySuite) TestPushContext(c *C) {
_, err = s.Repository.CreateRemote(&config.RemoteConfig{
Name: "foo",
- URL: url,
+ URLs: []string{url},
})
c.Assert(err, IsNil)
diff --git a/storage/filesystem/config_test.go b/storage/filesystem/config_test.go
index 1b812e6..4226b33 100644
--- a/storage/filesystem/config_test.go
+++ b/storage/filesystem/config_test.go
@@ -5,6 +5,7 @@ import (
"os"
"github.com/src-d/go-git-fixtures"
+ "gopkg.in/src-d/go-git.v4/config"
"gopkg.in/src-d/go-git.v4/storage/filesystem/internal/dotgit"
. "gopkg.in/check.v1"
@@ -39,9 +40,8 @@ func (s *ConfigSuite) TestRemotes(c *C) {
c.Assert(remotes, HasLen, 1)
remote := remotes["origin"]
c.Assert(remote.Name, Equals, "origin")
- c.Assert(remote.URL, Equals, "https://github.com/git-fixtures/basic")
- c.Assert(remote.Fetch, HasLen, 1)
- c.Assert(remote.Fetch[0].String(), Equals, "+refs/heads/*:refs/remotes/origin/*")
+ c.Assert(remote.URLs, DeepEquals, []string{"https://github.com/git-fixtures/basic"})
+ c.Assert(remote.Fetch, DeepEquals, []config.RefSpec{config.RefSpec("+refs/heads/*:refs/remotes/origin/*")})
}
func (s *ConfigSuite) TearDownTest(c *C) {
diff --git a/storage/test/storage_suite.go b/storage/test/storage_suite.go
index 7cb0fe3..ac1baa0 100644
--- a/storage/test/storage_suite.go
+++ b/storage/test/storage_suite.go
@@ -351,7 +351,7 @@ func (s *BaseStorageSuite) TestSetConfigAndConfig(c *C) {
expected.Core.IsBare = true
expected.Remotes["foo"] = &config.RemoteConfig{
Name: "foo",
- URL: "http://foo/bar.git",
+ URLs: []string{"http://foo/bar.git"},
}
err := s.Storer.SetConfig(expected)
diff --git a/submodule.go b/submodule.go
index fbaddfd..cf90c63 100644
--- a/submodule.go
+++ b/submodule.go
@@ -130,7 +130,7 @@ func (s *Submodule) Repository() (*Repository, error) {
_, err = r.CreateRemote(&config.RemoteConfig{
Name: DefaultRemoteName,
- URL: s.c.URL,
+ URLs: []string{s.c.URL},
})
return r, err
diff --git a/worktree_test.go b/worktree_test.go
index 10774a4..c14d3bc 100644
--- a/worktree_test.go
+++ b/worktree_test.go
@@ -37,7 +37,7 @@ func (s *WorktreeSuite) TestPullCheckout(c *C) {
r, _ := Init(memory.NewStorage(), fs)
r.CreateRemote(&config.RemoteConfig{
Name: DefaultRemoteName,
- URL: s.GetBasicLocalRepositoryURL(),
+ URLs: []string{s.GetBasicLocalRepositoryURL()},
})
w, err := r.Worktree()
@@ -115,7 +115,7 @@ func (s *WorktreeSuite) TestPullUpdateReferencesIfNeeded(c *C) {
r, _ := Init(memory.NewStorage(), memfs.New())
r.CreateRemote(&config.RemoteConfig{
Name: DefaultRemoteName,
- URL: s.GetBasicLocalRepositoryURL(),
+ URLs: []string{s.GetBasicLocalRepositoryURL()},
})
err := r.Fetch(&FetchOptions{})
@@ -173,7 +173,7 @@ func (s *WorktreeSuite) TestPullProgress(c *C) {
r.CreateRemote(&config.RemoteConfig{
Name: DefaultRemoteName,
- URL: s.GetBasicLocalRepositoryURL(),
+ URLs: []string{s.GetBasicLocalRepositoryURL()},
})
w, err := r.Worktree()
@@ -198,7 +198,7 @@ func (s *WorktreeSuite) TestPullProgressWithRecursion(c *C) {
r, _ := PlainInit(dir, false)
r.CreateRemote(&config.RemoteConfig{
Name: DefaultRemoteName,
- URL: path,
+ URLs: []string{path},
})
w, err := r.Worktree()