Skip to content

Commit 4de5cd9

Browse files
Zettat123delvhjolheiser
authored
Return empty url for submodule tree entries (#23043)
Close #22614. Refer to [Github's API](https://docs.github.com/en/rest/git/trees?apiVersion=2022-11-28#get-a-tree), if a tree entry is a submodule, its url will be an empty string. --------- Co-authored-by: delvh <[email protected]> Co-authored-by: John Olheiser <[email protected]>
1 parent a7e98d7 commit 4de5cd9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

services/repository/files/tree.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ func GetTreeBySHA(ctx context.Context, repo *repo_model.Repository, gitRepo *git
8585
if entries[e].IsDir() {
8686
copy(treeURL[copyPos:], entries[e].ID.String())
8787
tree.Entries[i].URL = string(treeURL)
88+
} else if entries[e].IsSubModule() {
89+
// In Github Rest API Version=2022-11-28, if a tree entry is a submodule,
90+
// its url will be returned as an empty string.
91+
// So the URL will be set to "" here.
92+
tree.Entries[i].URL = ""
8893
} else {
8994
copy(blobURL[copyPos:], entries[e].ID.String())
9095
tree.Entries[i].URL = string(blobURL)

0 commit comments

Comments
 (0)