diff options
Diffstat (limited to 'modules/git/commit_info.go')
-rw-r--r-- | modules/git/commit_info.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/modules/git/commit_info.go b/modules/git/commit_info.go index c046acbb50..b44e9fa51d 100644 --- a/modules/git/commit_info.go +++ b/modules/git/commit_info.go @@ -3,9 +3,24 @@ package git +import "path" + // CommitInfo describes the first commit with the provided entry type CommitInfo struct { Entry *TreeEntry Commit *Commit SubmoduleFile *CommitSubmoduleFile } + +func getCommitInfoSubmoduleFile(repoLink string, entry *TreeEntry, commit *Commit, treePathDir string) (*CommitSubmoduleFile, error) { + fullPath := path.Join(treePathDir, entry.Name()) + submodule, err := commit.GetSubModule(fullPath) + if err != nil { + return nil, err + } + if submodule == nil { + // unable to find submodule from ".gitmodules" file + return NewCommitSubmoduleFile(repoLink, fullPath, "", entry.ID.String()), nil + } + return NewCommitSubmoduleFile(repoLink, fullPath, submodule.URL, entry.ID.String()), nil +} |