summaryrefslogtreecommitdiffstats
path: root/pkg/commands/models/submodule_config.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/commands/models/submodule_config.go')
-rw-r--r--pkg/commands/models/submodule_config.go31
1 files changed, 30 insertions, 1 deletions
diff --git a/pkg/commands/models/submodule_config.go b/pkg/commands/models/submodule_config.go
index f52576921..7df0d131a 100644
--- a/pkg/commands/models/submodule_config.go
+++ b/pkg/commands/models/submodule_config.go
@@ -1,15 +1,35 @@
package models
+import "path/filepath"
+
type SubmoduleConfig struct {
Name string
Path string
Url string
+
+ ParentModule *SubmoduleConfig // nil if top-level
}
-func (r *SubmoduleConfig) RefName() string {
+func (r *SubmoduleConfig) FullName() string {
+ if r.ParentModule != nil {
+ return r.ParentModule.FullName() + "/" + r.Name
+ }
+
return r.Name
}
+func (r *SubmoduleConfig) FullPath() string {
+ if r.ParentModule != nil {
+ return r.ParentModule.FullPath() + "/" + r.Path
+ }
+
+ return r.Path
+}
+
+func (r *SubmoduleConfig) RefName() string {
+ return r.FullName()
+}
+
func (r *SubmoduleConfig) ID() string {
return r.RefName()
}
@@ -17,3 +37,12 @@ func (r *SubmoduleConfig) ID() string {
func (r *SubmoduleConfig) Description() string {
return r.RefName()
}
+
+func (r *SubmoduleConfig) GitDirPath(repoGitDirPath string) string {
+ parentPath := repoGitDirPath
+ if r.ParentModule != nil {
+ parentPath = r.ParentModule.GitDirPath(repoGitDirPath)
+ }
+
+ return filepath.Join(parentPath, "modules", r.Name)
+}