99	"bytes" 
1010	"context" 
1111	"errors" 
12- 	"fmt" 
1312	"io" 
1413	"os/exec" 
1514	"strconv" 
@@ -29,7 +28,7 @@ type Commit struct {
2928	Signature      * CommitSignature 
3029
3130	Parents         []ObjectID  // ID strings 
32- 	submoduleCache  * ObjectCache 
31+ 	submoduleCache  * ObjectCache [ * SubModule ] 
3332}
3433
3534// CommitSignature represents a git commit signature part. 
@@ -357,69 +356,6 @@ func (c *Commit) GetFileContent(filename string, limit int) (string, error) {
357356	return  string (bytes ), nil 
358357}
359358
360- // GetSubModules get all the sub modules of current revision git tree 
361- func  (c  * Commit ) GetSubModules () (* ObjectCache , error ) {
362- 	if  c .submoduleCache  !=  nil  {
363- 		return  c .submoduleCache , nil 
364- 	}
365- 
366- 	entry , err  :=  c .GetTreeEntryByPath (".gitmodules" )
367- 	if  err  !=  nil  {
368- 		if  _ , ok  :=  err .(ErrNotExist ); ok  {
369- 			return  nil , nil 
370- 		}
371- 		return  nil , err 
372- 	}
373- 
374- 	rd , err  :=  entry .Blob ().DataAsync ()
375- 	if  err  !=  nil  {
376- 		return  nil , err 
377- 	}
378- 
379- 	defer  rd .Close ()
380- 	scanner  :=  bufio .NewScanner (rd )
381- 	c .submoduleCache  =  newObjectCache ()
382- 	var  ismodule  bool 
383- 	var  path  string 
384- 	for  scanner .Scan () {
385- 		if  strings .HasPrefix (scanner .Text (), "[submodule" ) {
386- 			ismodule  =  true 
387- 			continue 
388- 		}
389- 		if  ismodule  {
390- 			fields  :=  strings .Split (scanner .Text (), "=" )
391- 			k  :=  strings .TrimSpace (fields [0 ])
392- 			if  k  ==  "path"  {
393- 				path  =  strings .TrimSpace (fields [1 ])
394- 			} else  if  k  ==  "url"  {
395- 				c .submoduleCache .Set (path , & SubModule {path , strings .TrimSpace (fields [1 ])})
396- 				ismodule  =  false 
397- 			}
398- 		}
399- 	}
400- 	if  err  =  scanner .Err (); err  !=  nil  {
401- 		return  nil , fmt .Errorf ("GetSubModules scan: %w" , err )
402- 	}
403- 
404- 	return  c .submoduleCache , nil 
405- }
406- 
407- // GetSubModule get the sub module according entryname 
408- func  (c  * Commit ) GetSubModule (entryname  string ) (* SubModule , error ) {
409- 	modules , err  :=  c .GetSubModules ()
410- 	if  err  !=  nil  {
411- 		return  nil , err 
412- 	}
413- 
414- 	if  modules  !=  nil  {
415- 		module , has  :=  modules .Get (entryname )
416- 		if  has  {
417- 			return  module .(* SubModule ), nil 
418- 		}
419- 	}
420- 	return  nil , nil 
421- }
422- 
423359// GetBranchName gets the closest branch name (as returned by 'git name-rev --name-only') 
424360func  (c  * Commit ) GetBranchName () (string , error ) {
425361	cmd  :=  NewCommand (c .repo .Ctx , "name-rev" )
0 commit comments