Skip to content

Commit 4ddfe0d

Browse files
authored
Fix GetContents(): Dont't ignore Executables (#11192)
* Refactor: dont expose help functions * repofiles GetContents: dont ignore executables * CI.restart()
1 parent 812cfd0 commit 4ddfe0d

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

modules/repofiles/content.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func GetContents(repo *models.Repository, treePath, ref string, forList bool) (*
159159
}
160160

161161
// Now populate the rest of the ContentsResponse based on entry type
162-
if entry.IsRegular() {
162+
if entry.IsRegular() || entry.IsExecutable() {
163163
contentsResponse.Type = string(ContentTypeRegular)
164164
if blobResponse, err := GetBlobBySHA(repo, entry.ID.String()); err != nil {
165165
return nil, err

routers/api/v1/repo/file.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,13 @@ func GetEditorconfig(ctx *context.APIContext) {
155155
ctx.JSON(http.StatusOK, def)
156156
}
157157

158-
// CanWriteFiles returns true if repository is editable and user has proper access level.
159-
func CanWriteFiles(r *context.Repository) bool {
158+
// canWriteFiles returns true if repository is editable and user has proper access level.
159+
func canWriteFiles(r *context.Repository) bool {
160160
return r.Permission.CanWrite(models.UnitTypeCode) && !r.Repository.IsMirror && !r.Repository.IsArchived
161161
}
162162

163-
// CanReadFiles returns true if repository is readable and user has proper access level.
164-
func CanReadFiles(r *context.Repository) bool {
163+
// canReadFiles returns true if repository is readable and user has proper access level.
164+
func canReadFiles(r *context.Repository) bool {
165165
return r.Permission.CanRead(models.UnitTypeCode)
166166
}
167167

@@ -321,7 +321,7 @@ func UpdateFile(ctx *context.APIContext, apiOpts api.UpdateFileOptions) {
321321

322322
// Called from both CreateFile or UpdateFile to handle both
323323
func createOrUpdateFile(ctx *context.APIContext, opts *repofiles.UpdateRepoFileOptions) (*api.FileResponse, error) {
324-
if !CanWriteFiles(ctx.Repo) {
324+
if !canWriteFiles(ctx.Repo) {
325325
return nil, models.ErrUserDoesNotHaveAccessToRepo{
326326
UserID: ctx.User.ID,
327327
RepoName: ctx.Repo.Repository.LowerName,
@@ -377,7 +377,7 @@ func DeleteFile(ctx *context.APIContext, apiOpts api.DeleteFileOptions) {
377377
// "404":
378378
// "$ref": "#/responses/error"
379379

380-
if !CanWriteFiles(ctx.Repo) {
380+
if !canWriteFiles(ctx.Repo) {
381381
ctx.Error(http.StatusForbidden, "DeleteFile", models.ErrUserDoesNotHaveAccessToRepo{
382382
UserID: ctx.User.ID,
383383
RepoName: ctx.Repo.Repository.LowerName,
@@ -474,7 +474,7 @@ func GetContents(ctx *context.APIContext) {
474474
// "404":
475475
// "$ref": "#/responses/notFound"
476476

477-
if !CanReadFiles(ctx.Repo) {
477+
if !canReadFiles(ctx.Repo) {
478478
ctx.Error(http.StatusInternalServerError, "GetContentsOrList", models.ErrUserDoesNotHaveAccessToRepo{
479479
UserID: ctx.User.ID,
480480
RepoName: ctx.Repo.Repository.LowerName,

0 commit comments

Comments
 (0)