GetSubModules get all the sub modules of current revision git tree.
(rd *BlobReader)
| 66 | |
| 67 | // GetSubModules get all the sub modules of current revision git tree. |
| 68 | func 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 | } |
no test coverage detected
searching dependent graphs…