aboutsummaryrefslogtreecommitdiffstats
path: root/formats/config
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-11-07 20:29:58 +0100
committerGitHub <noreply@github.com>2016-11-07 20:29:58 +0100
commit0ff9ef2b44c53e557c78bde0fd9c29847e5f0e23 (patch)
treeb9c7485fe99e6e89fa736ceb0223aeb2ecddb77c /formats/config
parentf6ed7424cbf33c7013332d7e95b4262a4bc4a523 (diff)
downloadgo-git-0ff9ef2b44c53e557c78bde0fd9c29847e5f0e23.tar.gz
global storage interface refactor (#112)
* core: ObjectStorage, ReferenceStorage renamed to ObjectStorer and ReferenceStorer * rebase * general, changes request by @alcortes * general, changes request by @alcortes
Diffstat (limited to 'formats/config')
-rw-r--r--formats/config/common.go1
-rw-r--r--formats/config/doc.go3
-rw-r--r--formats/config/section.go47
3 files changed, 26 insertions, 25 deletions
diff --git a/formats/config/common.go b/formats/config/common.go
index e7292e9..d2f1e5c 100644
--- a/formats/config/common.go
+++ b/formats/config/common.go
@@ -32,6 +32,7 @@ func (c *Config) Section(name string) *Section {
return s
}
}
+
s := &Section{Name: name}
c.Sections = append(c.Sections, s)
return s
diff --git a/formats/config/doc.go b/formats/config/doc.go
index 1f7eb78..dd77fbc 100644
--- a/formats/config/doc.go
+++ b/formats/config/doc.go
@@ -1,5 +1,4 @@
-// Package config implements decoding, encoding and manipulation
-// of git config files.
+// Package config implements decoding/encoding of git config files.
package config
/*
diff --git a/formats/config/section.go b/formats/config/section.go
index 552ce74..1844913 100644
--- a/formats/config/section.go
+++ b/formats/config/section.go
@@ -21,28 +21,15 @@ func (s *Section) IsName(name string) bool {
return strings.ToLower(s.Name) == strings.ToLower(name)
}
-func (s *Subsection) IsName(name string) bool {
- return s.Name == name
-}
-
func (s *Section) Option(key string) string {
return s.Options.Get(key)
}
-func (s *Subsection) Option(key string) string {
- return s.Options.Get(key)
-}
-
func (s *Section) AddOption(key string, value string) *Section {
s.Options = s.Options.withAddedOption(key, value)
return s
}
-func (s *Subsection) AddOption(key string, value string) *Subsection {
- s.Options = s.Options.withAddedOption(key, value)
- return s
-}
-
func (s *Section) SetOption(key string, value string) *Section {
s.Options = s.Options.withSettedOption(key, value)
return s
@@ -53,16 +40,6 @@ func (s *Section) RemoveOption(key string) *Section {
return s
}
-func (s *Subsection) SetOption(key string, value string) *Subsection {
- s.Options = s.Options.withSettedOption(key, value)
- return s
-}
-
-func (s *Subsection) RemoveOption(key string) *Subsection {
- s.Options = s.Options.withoutOption(key)
- return s
-}
-
func (s *Section) Subsection(name string) *Subsection {
for i := len(s.Subsections) - 1; i >= 0; i-- {
ss := s.Subsections[i]
@@ -70,6 +47,7 @@ func (s *Section) Subsection(name string) *Subsection {
return ss
}
}
+
ss := &Subsection{Name: name}
s.Subsections = append(s.Subsections, ss)
return ss
@@ -84,3 +62,26 @@ func (s *Section) HasSubsection(name string) bool {
return false
}
+
+func (s *Subsection) IsName(name string) bool {
+ return s.Name == name
+}
+
+func (s *Subsection) Option(key string) string {
+ return s.Options.Get(key)
+}
+
+func (s *Subsection) AddOption(key string, value string) *Subsection {
+ s.Options = s.Options.withAddedOption(key, value)
+ return s
+}
+
+func (s *Subsection) SetOption(key string, value string) *Subsection {
+ s.Options = s.Options.withSettedOption(key, value)
+ return s
+}
+
+func (s *Subsection) RemoveOption(key string) *Subsection {
+ s.Options = s.Options.withoutOption(key)
+ return s
+}