diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-02-21 16:07:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-21 16:07:25 +0100 |
commit | 867b10692e5f8a34a82cc0a783bdb63e2b5ff398 (patch) | |
tree | 3ddb2f430ee3c958f0650cb7db6a9df44b1e1361 /config/modules.go | |
parent | 0b8b8da617d5a077f282e57d0300dc106a604236 (diff) | |
parent | 790fbdaddc3c9a434f2ad97d9eb56db9b6c99495 (diff) | |
download | go-git-867b10692e5f8a34a82cc0a783bdb63e2b5ff398.tar.gz |
Merge pull request #270 from mcuadros/submodules-init
Submodules init and update
Diffstat (limited to 'config/modules.go')
-rw-r--r-- | config/modules.go | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/config/modules.go b/config/modules.go index 4d98b16..3d01117 100644 --- a/config/modules.go +++ b/config/modules.go @@ -15,7 +15,7 @@ var ( // Modules defines the submodules properties, represents a .gitmodules file // https://www.kernel.org/pub/software/scm/git/docs/gitmodules.html type Modules struct { - // Submodules is a map of submodules being the key the name of the submodule + // Submodules is a map of submodules being the key the name of the submodule. Submodules map[string]*Submodule raw *format.Config @@ -30,12 +30,11 @@ func NewModules() *Modules { } const ( - submoduleSection = "submodule" - pathKey = "path" - branchKey = "branch" + pathKey = "path" + branchKey = "branch" ) -// Unmarshal parses a git-config file and stores it +// Unmarshal parses a git-config file and stores it. func (m *Modules) Unmarshal(b []byte) error { r := bytes.NewBuffer(b) d := format.NewDecoder(r) @@ -56,7 +55,7 @@ func (m *Modules) Unmarshal(b []byte) error { return nil } -// Marshal returns Modules encoded as a git-config file +// Marshal returns Modules encoded as a git-config file. func (m *Modules) Marshal() ([]byte, error) { s := m.raw.Section(submoduleSection) s.Subsections = make(format.Subsections, len(m.Submodules)) @@ -75,12 +74,12 @@ func (m *Modules) Marshal() ([]byte, error) { return buf.Bytes(), nil } -// Submodule defines a submodule +// Submodule defines a submodule. type Submodule struct { // Name module name Name string // Path defines the path, relative to the top-level directory of the Git - // working tree, + // working tree. Path string // URL defines a URL from which the submodule repository can be cloned. URL string @@ -89,11 +88,11 @@ type Submodule struct { Branch string // raw representation of the subsection, filled by marshal or unmarshal are - // called + // called. raw *format.Subsection } -// Validate validates the fields and sets the default values +// Validate validates the fields and sets the default values. func (m *Submodule) Validate() error { if m.Path == "" { return ErrModuleEmptyPath |