aboutsummaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2022-07-21 21:18:41 +0200
committerGitHub <noreply@github.com>2022-07-21 21:18:41 +0200
commit0a97480934fc2082c9cff18a5b66cedc12575919 (patch)
tree8f756dd6e2abaefd9909e3e438b22b8ecae292d6 /services
parent7690de56f7bdcc5065af2c9478e8572d318a84f3 (diff)
downloadgitea-0a97480934fc2082c9cff18a5b66cedc12575919.tar.gz
gitea-0a97480934fc2082c9cff18a5b66cedc12575919.zip
Add "X-Gitea-Object-Type" header for GET `/raw/` & `/media/` API (#20438)
Diffstat (limited to 'services')
-rw-r--r--services/repository/files/content.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/services/repository/files/content.go b/services/repository/files/content.go
index 2237671a60..c206909289 100644
--- a/services/repository/files/content.go
+++ b/services/repository/files/content.go
@@ -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 == "" {