mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Add "X-Gitea-Object-Type" header for GET /raw/
& /media/
API (#20438)
This commit is contained in:
@@ -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 == "" {
|
||||
|
Reference in New Issue
Block a user