diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-08-10 11:26:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-10 11:26:45 +0200 |
commit | a2b4a32505535b46e8daa185cbd4c7703678c936 (patch) | |
tree | 55831dd4b0ce3e16fe1717a5033c7dfdc4ad1888 | |
parent | da410ded51ddab7729992540b54c739e43090244 (diff) | |
parent | 0f8ed5664c38605fbb849017214cebbf5de50666 (diff) | |
download | go-git-a2b4a32505535b46e8daa185cbd4c7703678c936.tar.gz |
Merge pull request #542 from mcarmonaa/fix/config-marhal
serialized remotes in alphabetical order
-rw-r--r-- | config/config.go | 12 | ||||
-rw-r--r-- | config/config_test.go | 4 |
2 files changed, 12 insertions, 4 deletions
diff --git a/config/config.go b/config/config.go index cb10738..475045e 100644 --- a/config/config.go +++ b/config/config.go @@ -5,6 +5,7 @@ import ( "bytes" "errors" "fmt" + "sort" format "gopkg.in/src-d/go-git.v4/plumbing/format/config" ) @@ -168,9 +169,16 @@ func (c *Config) marshalRemotes() { } } - for name, remote := range c.Remotes { + remoteNames := make([]string, 0, len(c.Remotes)) + for name := range c.Remotes { + remoteNames = append(remoteNames, name) + } + + sort.Strings(remoteNames) + + for _, name := range remoteNames { if !added[name] { - newSubsections = append(newSubsections, remote.marshal()) + newSubsections = append(newSubsections, c.Remotes[name].marshal()) } } diff --git a/config/config_test.go b/config/config_test.go index 97f4bbf..c27ee26 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -51,13 +51,13 @@ func (s *ConfigSuite) TestMarshall(c *C) { output := []byte(`[core] bare = true 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/* +[remote "origin"] + url = git@github.com:mcuadros/go-git.git [submodule "qux"] url = https://github.com/foo/qux.git `) |