Skip to content

Commit 874865e

Browse files
authored
modify the url from /contents to /commit_contents to fix bug about cant get information from sub dir (go-gitea#8)
Signed-off-by: Tom_zc <[email protected]> Co-authored-by: Tom_zc <[email protected]>
1 parent 422d493 commit 874865e

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed

routers/api/v1/api.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1211,8 +1211,11 @@ func Routes() *web.Route {
12111211
m.Get("/notes/{sha}", repo.GetNote)
12121212
}, context.ReferencesGitRepo(true), reqRepoReader(unit.TypeCode))
12131213
m.Post("/diffpatch", reqRepoWriter(unit.TypeCode), reqToken(), bind(api.ApplyDiffPatchFileOptions{}), mustNotBeArchived, repo.ApplyDiffPatch)
1214+
m.Group("/commit_contents", func() {
1215+
m.Get("", repo.GetCommitsContentsList)
1216+
m.Get("/*", repo.GetCommitsContents)
1217+
}, reqRepoReader(unit.TypeCode))
12141218
m.Group("/contents", func() {
1215-
m.Get("/commits", repo.GetCommitsContentsList)
12161219
m.Get("", repo.GetContentsList)
12171220
m.Post("", reqToken(), bind(api.ChangeFilesOptions{}), reqRepoBranchWriter, mustNotBeArchived, repo.ChangeFiles)
12181221
m.Get("/*", repo.GetContents)

routers/api/v1/repo/file.go

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -975,9 +975,9 @@ func GetContentsList(ctx *context.APIContext) {
975975
GetContents(ctx)
976976
}
977977

978-
// GetCommitsContentsList Get the metadata (include commit information) of all the entries of the root dir
979-
func GetCommitsContentsList(ctx *context.APIContext) {
980-
// swagger:operation GET /repos/{owner}/{repo}/contents/commits repository repoGetContentsList
978+
// GetCommitsContents Get the metadata and commit and contents (if a file) of an entry in a repository, or a list of entries if a dir
979+
func GetCommitsContents(ctx *context.APIContext) {
980+
// swagger:operation GET /repos/{owner}/{repo}/commit_contents/commits repository repoGetContentsList
981981
// ---
982982
// summary: Gets the metadata of all the entries of the root dir
983983
// produces:
@@ -1025,4 +1025,39 @@ func GetCommitsContentsList(ctx *context.APIContext) {
10251025
} else {
10261026
ctx.JSON(http.StatusOK, fileList)
10271027
}
1028+
1029+
}
1030+
1031+
// GetCommitsContentsList Get the metadata (include commit information) of all the entries of the root dir
1032+
func GetCommitsContentsList(ctx *context.APIContext) {
1033+
// swagger:operation GET /repos/{owner}/{repo}/commit_contents repository repoGetContentsList
1034+
// ---
1035+
// summary: Gets the metadata of all the entries of the root dir
1036+
// produces:
1037+
// - application/json
1038+
// parameters:
1039+
// - name: owner
1040+
// in: path
1041+
// description: owner of the repo
1042+
// type: string
1043+
// required: true
1044+
// - name: repo
1045+
// in: path
1046+
// description: name of the repo
1047+
// type: string
1048+
// required: true
1049+
// - name: ref
1050+
// in: query
1051+
// description: "The name of the commit/branch/tag. Default the repository’s default branch (usually master)"
1052+
// type: string
1053+
// required: false
1054+
// responses:
1055+
// "200":
1056+
// "$ref": "#/responses/ContentsListResponse"
1057+
// "404":
1058+
// "$ref": "#/responses/notFound"
1059+
1060+
// same as GetContents(), this function is here because swagger fails if path is empty in GetContents() interface
1061+
GetCommitsContents(ctx)
1062+
10281063
}

0 commit comments

Comments
 (0)