Пример #1
0
func (c *ConfigStorage) Config() (*config.Config, error) {
	if c.config == nil {
		c.config = config.NewConfig()
	}

	return c.config, nil
}
Пример #2
0
func (s *BaseStorageSuite) TestSetConfigInvalid(c *C) {
	cfg := config.NewConfig()
	cfg.Remotes["foo"] = &config.RemoteConfig{}

	err := s.Storer.SetConfig(cfg)
	c.Assert(err, NotNil)
}
Пример #3
0
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
}
Пример #4
0
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)
}
Пример #5
0
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
}