mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-31 11:52:10 +00:00
Add "X-Gitea-Object-Type" header for GET /raw/
& /media/
API (#20438)
This commit is contained in:
parent
7690de56f7
commit
0a97480934
3 changed files with 32 additions and 6 deletions
|
@ -101,6 +101,22 @@ func GetContentsOrList(ctx context.Context, repo *repo_model.Repository, treePat
|
|||
return fileList, nil
|
||||
}
|
||||
|
||||
// GetObjectTypeFromTreeEntry check what content is behind it
|
||||
func GetObjectTypeFromTreeEntry(entry *git.TreeEntry) ContentType {
|
||||
switch {
|
||||
case entry.IsDir():
|
||||
return ContentTypeDir
|
||||
case entry.IsSubModule():
|
||||
return ContentTypeSubmodule
|
||||
case entry.IsExecutable(), entry.IsRegular():
|
||||
return ContentTypeRegular
|
||||
case entry.IsLink():
|
||||
return ContentTypeLink
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
// GetContents gets the meta data on a file's contents. Ref can be a branch, commit or tag
|
||||
func GetContents(ctx context.Context, repo *repo_model.Repository, treePath, ref string, forList bool) (*api.ContentsResponse, error) {
|
||||
if ref == "" {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue