[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 ca32891d548c302b0f3b3072647058278ffb9cbf)
(cherry picked from commit 72c9df8e457ea291f767e6edf2b3c8f9af15700f)
(cherry picked from commit 0eae22d429a66f137daa200f559883a6b6a31de0)
(cherry picked from commit d37d0773bc005df19f300f9ada03632ea9f97642)
(cherry picked from commit de4532a96721ed4259aa36cb417bb49ed979f6e5)
(cherry picked from commit f5b41300a86222308eb605c84945ed7c9770b04d)
(cherry picked from commit d3be0480b78ec2edbd78c4c0685f097b2ee841d6)
(cherry picked from commit c72307fd3bbb6b29cffe112dd71c70871595a0ce)
(cherry picked from commit 71db59305787decb1beb817d399bb3ffc2b78566)
(cherry picked from commit 568e668fb8d707b84ba0ba47c2ed9e2ef35df4c5)
This commit is contained in:
Gusted 2023-11-28 12:46:34 +01:00 committed by Earl Warren
parent e1a82a15d3
commit 9341b37520
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 0579CB2928A78A00

View file

@ -220,7 +220,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