File tree Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -379,24 +379,31 @@ func (c *Commit) GetSubModules() (*ObjectCache, error) {
379
379
defer rd .Close ()
380
380
scanner := bufio .NewScanner (rd )
381
381
c .submoduleCache = newObjectCache ()
382
- var ismodule bool
383
- var path string
382
+ var subModule * SubModule
384
383
for scanner .Scan () {
385
- if strings .HasPrefix (scanner .Text (), "[submodule" ) {
386
- ismodule = true
384
+ if strings .HasPrefix (scanner .Text (), "[" ) {
385
+ if subModule != nil {
386
+ c .submoduleCache .Set (subModule .Name , subModule )
387
+ subModule = nil
388
+ }
389
+ if strings .HasPrefix (scanner .Text (), "[submodule" ) {
390
+ subModule = & SubModule {}
391
+ }
387
392
continue
388
393
}
389
- if ismodule {
394
+ if subModule != nil {
390
395
fields := strings .Split (scanner .Text (), "=" )
391
396
k := strings .TrimSpace (fields [0 ])
392
397
if k == "path" {
393
- path = strings .TrimSpace (fields [1 ])
398
+ subModule . Name = strings .TrimSpace (fields [1 ])
394
399
} else if k == "url" {
395
- c .submoduleCache .Set (path , & SubModule {path , strings .TrimSpace (fields [1 ])})
396
- ismodule = false
400
+ subModule .URL = strings .TrimSpace (fields [1 ])
397
401
}
398
402
}
399
403
}
404
+ if subModule != nil {
405
+ c .submoduleCache .Set (subModule .Name , subModule )
406
+ }
400
407
if err = scanner .Err (); err != nil {
401
408
return nil , fmt .Errorf ("GetSubModules scan: %w" , err )
402
409
}
You can’t perform that action at this time.
0 commit comments