Skip to content

Commit ca0a1fe

Browse files
committed
fix
1 parent 0d00ec7 commit ca0a1fe

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

modules/git/commit_info.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type CommitInfo struct {
1515
func getCommitInfoSubmoduleFile(repoLink string, entry *TreeEntry, commit *Commit, treePathDir string) (*CommitSubmoduleFile, error) {
1616
fullPath := path.Join(treePathDir, entry.Name())
1717
submodule, err := commit.GetSubModule(fullPath)
18-
if err != nil {
18+
if submodule == nil || err != nil {
1919
return nil, err
2020
}
2121
return NewCommitSubmoduleFile(repoLink, fullPath, submodule.URL, entry.ID.String()), nil

modules/git/commit_submodule.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ func (c *Commit) GetSubModules() (*ObjectCache[*SubModule], error) {
3535
return c.submoduleCache, nil
3636
}
3737

38-
// GetSubModule get the submodule according entry name
38+
// GetSubModule gets the submodule by the entry name.
39+
// It returns "nil, nil" if the submodule does not exist, caller should always remember to check the "nil"
3940
func (c *Commit) GetSubModule(entryName string) (*SubModule, error) {
4041
modules, err := c.GetSubModules()
4142
if err != nil {

0 commit comments

Comments
 (0)