diff options
author | Zettat123 <zettat123@gmail.com> | 2023-02-22 01:31:17 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-21 12:31:17 -0500 |
commit | 4de5cd9f367fe73815b1c72ffc54a5118cc8e1d6 (patch) | |
tree | f94db8c5f7d4b7b1e748ab84b7f4a300d8637c3f /services | |
parent | a7e98d70b6f20a80e0f98696e9445ff99546676a (diff) | |
download | gitea-4de5cd9f367fe73815b1c72ffc54a5118cc8e1d6.tar.gz gitea-4de5cd9f367fe73815b1c72ffc54a5118cc8e1d6.zip |
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 <leon@kske.dev>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Diffstat (limited to 'services')
-rw-r--r-- | services/repository/files/tree.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/services/repository/files/tree.go b/services/repository/files/tree.go index f4304ea630..0b1d304845 100644 --- a/services/repository/files/tree.go +++ b/services/repository/files/tree.go @@ -85,6 +85,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) |