Merge pull request 'fix: return correct type in GetSubModule' (#6114) from gusted/forgejo-submodule-entry into forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6114
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
This commit is contained in:
Gusted 2024-12-03 03:24:01 +00:00
commit 45cec645de
4 changed files with 46 additions and 12 deletions

View file

@ -211,12 +211,12 @@ func GetContents(ctx context.Context, repo *repo_model.Repository, treePath, ref
contentsResponse.Target = &targetFromContent
} else if entry.IsSubModule() {
contentsResponse.Type = string(ContentTypeSubmodule)
submodule, err := commit.GetSubModule(treePath)
submoduleURL, err := commit.GetSubModule(treePath)
if err != nil {
return nil, err
}
if submodule != nil && submodule.URL != "" {
contentsResponse.SubmoduleGitURL = &submodule.URL
if submoduleURL != "" {
contentsResponse.SubmoduleGitURL = &submoduleURL
}
}
// Handle links