mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-08 14:03:24 +09:00
enhance(api): expose file mode in contents API response (#38713)
This commit is contained in:
@@ -139,6 +139,8 @@ type ContentsResponse struct {
|
|||||||
|
|
||||||
// `type` will be `file`, `dir`, `symlink`, or `submodule`
|
// `type` will be `file`, `dir`, `symlink`, or `submodule`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
|
// `mode` is the Git file mode as an octal string, e.g. `100644` (regular), `100755` (executable), `120000` (symlink), `160000` (submodule)
|
||||||
|
Mode string `json:"mode"`
|
||||||
// Size is the file size in bytes
|
// Size is the file size in bytes
|
||||||
Size int64 `json:"size"`
|
Size int64 `json:"size"`
|
||||||
// `encoding` is populated when `type` is `file`, otherwise null
|
// `encoding` is populated when `type` is `file`, otherwise null
|
||||||
|
|||||||
@@ -148,6 +148,7 @@ func getFileContentsByEntryInternal(ctx context.Context, repo *repo_model.Reposi
|
|||||||
Name: entry.Name(),
|
Name: entry.Name(),
|
||||||
Path: opts.TreePath,
|
Path: opts.TreePath,
|
||||||
SHA: entry.ID.String(),
|
SHA: entry.ID.String(),
|
||||||
|
Mode: entry.Mode().String(),
|
||||||
Size: entry.GetSize(ctx, gitRepo),
|
Size: entry.GetSize(ctx, gitRepo),
|
||||||
URL: &selfURLString,
|
URL: &selfURLString,
|
||||||
Links: &api.FileLinksResponse{
|
Links: &api.FileLinksResponse{
|
||||||
|
|||||||
+5
@@ -3594,6 +3594,11 @@
|
|||||||
"type": "integer",
|
"type": "integer",
|
||||||
"x-go-name": "LfsSize"
|
"x-go-name": "LfsSize"
|
||||||
},
|
},
|
||||||
|
"mode": {
|
||||||
|
"description": "`mode` is the Git file mode as an octal string, e.g. `100644` (regular), `100755` (executable), `120000` (symlink), `160000` (submodule)",
|
||||||
|
"type": "string",
|
||||||
|
"x-go-name": "Mode"
|
||||||
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"description": "Name is the file or directory name",
|
"description": "Name is the file or directory name",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|||||||
+5
@@ -23998,6 +23998,11 @@
|
|||||||
"format": "int64",
|
"format": "int64",
|
||||||
"x-go-name": "LfsSize"
|
"x-go-name": "LfsSize"
|
||||||
},
|
},
|
||||||
|
"mode": {
|
||||||
|
"description": "`mode` is the Git file mode as an octal string, e.g. `100644` (regular), `100755` (executable), `120000` (symlink), `160000` (submodule)",
|
||||||
|
"type": "string",
|
||||||
|
"x-go-name": "Mode"
|
||||||
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"description": "Name is the file or directory name",
|
"description": "Name is the file or directory name",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ func getExpectedFileResponseForCreate(info apiFileResponseInfo) *api.FileRespons
|
|||||||
LastAuthorDate: new(info.lastAuthorWhen),
|
LastAuthorDate: new(info.lastAuthorWhen),
|
||||||
Size: 16,
|
Size: 16,
|
||||||
Type: "file",
|
Type: "file",
|
||||||
|
Mode: "100644",
|
||||||
Encoding: &encoding,
|
Encoding: &encoding,
|
||||||
Content: &content,
|
Content: &content,
|
||||||
URL: &selfURL,
|
URL: &selfURL,
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ func getExpectedFileResponseForUpdate(info apiFileResponseInfo) *api.FileRespons
|
|||||||
LastCommitterDate: new(info.lastCommitterWhen),
|
LastCommitterDate: new(info.lastCommitterWhen),
|
||||||
LastAuthorDate: new(info.lastAuthorWhen),
|
LastAuthorDate: new(info.lastAuthorWhen),
|
||||||
Type: "file",
|
Type: "file",
|
||||||
|
Mode: "100644",
|
||||||
Size: 20,
|
Size: 20,
|
||||||
Encoding: &encoding,
|
Encoding: &encoding,
|
||||||
Content: &content,
|
Content: &content,
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ func getExpectedContentsListResponseForContents(ref, refType, lastCommitSHA stri
|
|||||||
LastCommitterDate: new(time.Date(2017, time.March, 19, 16, 47, 59, 0, time.FixedZone("", -14400))),
|
LastCommitterDate: new(time.Date(2017, time.March, 19, 16, 47, 59, 0, time.FixedZone("", -14400))),
|
||||||
LastAuthorDate: new(time.Date(2017, time.March, 19, 16, 47, 59, 0, time.FixedZone("", -14400))),
|
LastAuthorDate: new(time.Date(2017, time.March, 19, 16, 47, 59, 0, time.FixedZone("", -14400))),
|
||||||
Type: "file",
|
Type: "file",
|
||||||
|
Mode: "100644",
|
||||||
Size: 30,
|
Size: 30,
|
||||||
URL: &selfURL,
|
URL: &selfURL,
|
||||||
HTMLURL: &htmlURL,
|
HTMLURL: &htmlURL,
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ func getExpectedContentsResponseForContents(inputRef string, expectedRef git.Ref
|
|||||||
LastCommitterDate: new(time.Date(2017, time.March, 19, 16, 47, 59, 0, time.FixedZone("", -14400))),
|
LastCommitterDate: new(time.Date(2017, time.March, 19, 16, 47, 59, 0, time.FixedZone("", -14400))),
|
||||||
LastAuthorDate: new(time.Date(2017, time.March, 19, 16, 47, 59, 0, time.FixedZone("", -14400))),
|
LastAuthorDate: new(time.Date(2017, time.March, 19, 16, 47, 59, 0, time.FixedZone("", -14400))),
|
||||||
Type: "file",
|
Type: "file",
|
||||||
|
Mode: "100644",
|
||||||
Size: 30,
|
Size: 30,
|
||||||
Encoding: new("base64"),
|
Encoding: new("base64"),
|
||||||
Content: new("IyByZXBvMQoKRGVzY3JpcHRpb24gZm9yIHJlcG8x"),
|
Content: new("IyByZXBvMQoKRGVzY3JpcHRpb24gZm9yIHJlcG8x"),
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ func getExpectedFileResponseForRepoFilesCreate(commitID string, lastCommit *git.
|
|||||||
LastCommitterDate: new(lastCommit.Committer.When),
|
LastCommitterDate: new(lastCommit.Committer.When),
|
||||||
LastAuthorDate: new(lastCommit.Author.When),
|
LastAuthorDate: new(lastCommit.Author.When),
|
||||||
Type: "file",
|
Type: "file",
|
||||||
|
Mode: "100644",
|
||||||
Size: 18,
|
Size: 18,
|
||||||
Encoding: &encoding,
|
Encoding: &encoding,
|
||||||
Content: &content,
|
Content: &content,
|
||||||
@@ -179,6 +180,7 @@ func getExpectedFileResponseForRepoFilesUpdate(commitID, filename, lastCommitSHA
|
|||||||
LastCommitterDate: new(lastCommitterWhen),
|
LastCommitterDate: new(lastCommitterWhen),
|
||||||
LastAuthorDate: new(lastAuthorWhen),
|
LastAuthorDate: new(lastAuthorWhen),
|
||||||
Type: "file",
|
Type: "file",
|
||||||
|
Mode: "100644",
|
||||||
Size: 43,
|
Size: 43,
|
||||||
Encoding: &encoding,
|
Encoding: &encoding,
|
||||||
Content: &content,
|
Content: &content,
|
||||||
@@ -283,6 +285,7 @@ func getExpectedFileResponseForRepoFilesUpdateRename(commitID, lastCommitSHA str
|
|||||||
SHA: detail.sha,
|
SHA: detail.sha,
|
||||||
LastCommitSHA: new(lastCommitSHA),
|
LastCommitSHA: new(lastCommitSHA),
|
||||||
Type: "file",
|
Type: "file",
|
||||||
|
Mode: "100644",
|
||||||
Size: detail.size,
|
Size: detail.size,
|
||||||
Encoding: new("base64"),
|
Encoding: new("base64"),
|
||||||
Content: &detail.content,
|
Content: &detail.content,
|
||||||
|
|||||||
Reference in New Issue
Block a user