Skip to content

Commit

Permalink
Return empty url for submodule tree entries (#23043) (#23048)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
4 people authored Feb 21, 2023
1 parent bbfd345 commit 8f5b2f1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions services/repository/files/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ func GetTreeBySHA(ctx context.Context, repo *repo_model.Repository, gitRepo *git
if entries[e].IsDir() {
copy(treeURL[copyPos:], entries[e].ID.String())
tree.Entries[i].URL = string(treeURL)
} else if entries[e].IsSubModule() {
// In Github Rest API Version=2022-11-28, if a tree entry is a submodule,
// its url will be returned as an empty string.
// So the URL will be set to "" here.
tree.Entries[i].URL = ""
} else {
copy(blobURL[copyPos:], entries[e].ID.String())
tree.Entries[i].URL = string(blobURL)
Expand Down

0 comments on commit 8f5b2f1

Please sign in to comment.