Skip to content

Commit

Permalink
Return empty url for submodule tree entries (go-gitea#23043) (go-gite…
Browse files Browse the repository at this point in the history
…a#23048)

Backport go-gitea#23043

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: Zettat123 <zettat123@gmail.com>
Co-authored-by: delvh <leon@kske.dev>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
(cherry picked from commit 8f5b2f1)
  • Loading branch information
yardenshoham authored and Loïc Dachary committed Feb 23, 2023
1 parent 9ae1268 commit 03864f7
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 03864f7

Please sign in to comment.