MCPcopy
hub / github.com/harness/harness / GetSubModules

Function GetSubModules

git/api/submodule.go:68–91  ·  view source on GitHub ↗

GetSubModules get all the sub modules of current revision git tree.

(rd *BlobReader)

Source from the content-addressed store, hash-verified

66
67// GetSubModules get all the sub modules of current revision git tree.
68func GetSubModules(rd *BlobReader) (map[string]*Submodule, error) {
69 var isModule bool
70 var path string
71 submodules := make(map[string]*Submodule, 4)
72 scanner := bufio.NewScanner(rd.Content)
73 for scanner.Scan() {
74 if strings.HasPrefix(scanner.Text(), "[submodule") {
75 isModule = true
76 continue
77 }
78 if isModule {
79 fields := strings.Split(scanner.Text(), "=")
80 k := strings.TrimSpace(fields[0])
81 if k == "path" {
82 path = strings.TrimSpace(fields[1])
83 } else if k == "url" {
84 submodules[path] = &Submodule{path, strings.TrimSpace(fields[1])}
85 isModule = false
86 }
87 }
88 }
89
90 return submodules, nil
91}

Callers 1

GetSubmoduleMethod · 0.85

Calls 3

ScanMethod · 0.95
TextMethod · 0.95
SplitMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…