0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-12-22 23:33:15 -05:00

[GITEA] Add download URL for executable files

- Consider executable files as a valid case when returning a downloadURL
for them. They are just regular files with the difference being the
executable permission bit being set.
- Not integration testing as it's not possible without adding adjusting
the existing repositories to have a executable file.
- Resolves https://codeberg.org/forgejo/forgejo/issues/1825

(cherry picked from commit ca32891d54)
(cherry picked from commit 72c9df8e45)
This commit is contained in:
Gusted 2023-11-28 12:46:34 +01:00 committed by Earl Warren
parent acd1456db9
commit 0eae22d429
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00

View file

@ -219,7 +219,7 @@ func GetContents(ctx context.Context, repo *repo_model.Repository, treePath, ref
}
}
// Handle links
if entry.IsRegular() || entry.IsLink() {
if entry.IsRegular() || entry.IsLink() || entry.IsExecutable() {
downloadURL, err := url.Parse(repo.HTMLURL() + "/raw/" + url.PathEscape(string(refType)) + "/" + util.PathEscapeSegments(ref) + "/" + util.PathEscapeSegments(treePath))
if err != nil {
return nil, err