Skip to content

Commit 8f5b2f1

Browse files
yardenshohamZettat123delvhjolheiser
authored
Return empty url for submodule tree entries (#23043) (#23048)
Backport #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: Zettat123 <zettat123@gmail.com> Co-authored-by: delvh <leon@kske.dev> Co-authored-by: John Olheiser <john.olheiser@gmail.com>
1 parent bbfd345 commit 8f5b2f1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

services/repository/files/tree.go

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

0 commit comments

Comments
 (0)