func (c *ConfigStorage) Config() (*config.Config, error) { if c.config == nil { c.config = config.NewConfig() } return c.config, nil }
func (s *BaseStorageSuite) TestSetConfigInvalid(c *C) { cfg := config.NewConfig() cfg.Remotes["foo"] = &config.RemoteConfig{} err := s.Storer.SetConfig(cfg) c.Assert(err, NotNil) }
func (c *ConfigStorage) Config() (*config.Config, error) { cfg := config.NewConfig() ini, err := c.unmarshal() if err != nil { return nil, err } c.unmarshalCore(cfg, ini) c.unmarshalRemotes(cfg, ini) return cfg, nil }
func (s *BaseStorageSuite) TestSetConfigAndConfig(c *C) { expected := config.NewConfig() expected.Core.IsBare = true expected.Remotes["foo"] = &config.RemoteConfig{ Name: "foo", URL: "http://foo/bar.git", } err := s.Storer.SetConfig(expected) c.Assert(err, IsNil) cfg, err := s.Storer.Config() c.Assert(err, IsNil) c.Assert(cfg, DeepEquals, expected) }
func (c *ConfigStorage) Config() (*config.Config, error) { cfg := config.NewConfig() ini, err := c.unmarshal() if err != nil { return nil, err } sect := ini.Section(remoteSection) for _, s := range sect.Subsections { r := c.unmarshalRemote(s) cfg.Remotes[r.Name] = r } return cfg, nil }