Skip to content

Commit

Permalink
Return empty url for submodule tree entries (go-gitea#23043)
Browse files Browse the repository at this point in the history
Close go-gitea#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 <leon@kske.dev>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
  • Loading branch information
3 people authored and yardenshoham committed Feb 21, 2023
1 parent bbfd345 commit fed6bb5
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 fed6bb5

Please sign in to comment.