Skip to content

Commit fd85d31

Browse files
lunnysapk
andauthored
Ensure executable bit is kept on the web editor (go-gitea#10607) (go-gitea#10614)
Co-authored-by: Antoine GIRARD <[email protected]> Co-authored-by: Antoine GIRARD <[email protected]>
1 parent c9e4d7a commit fd85d31

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

modules/repofiles/update.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ func CreateOrUpdateRepoFile(repo *models.Repository, doer *models.User, opts *Up
210210

211211
encoding := "UTF-8"
212212
bom := false
213+
executable := false
213214

214215
if !opts.IsNewFile {
215216
fromEntry, err := commit.GetTreeEntryByPath(fromTreePath)
@@ -245,6 +246,7 @@ func CreateOrUpdateRepoFile(repo *models.Repository, doer *models.User, opts *Up
245246
return nil, models.ErrSHAOrCommitIDNotProvided{}
246247
}
247248
encoding, bom = detectEncodingAndBOM(fromEntry, repo)
249+
executable = fromEntry.IsExecutable()
248250
}
249251

250252
// For the path where this file will be created/updated, we need to make
@@ -368,8 +370,14 @@ func CreateOrUpdateRepoFile(repo *models.Repository, doer *models.User, opts *Up
368370
}
369371

370372
// Add the object to the index
371-
if err := t.AddObjectToIndex("100644", objectHash, treePath); err != nil {
372-
return nil, err
373+
if executable {
374+
if err := t.AddObjectToIndex("100755", objectHash, treePath); err != nil {
375+
return nil, err
376+
}
377+
} else {
378+
if err := t.AddObjectToIndex("100644", objectHash, treePath); err != nil {
379+
return nil, err
380+
}
373381
}
374382

375383
// Now write the tree

0 commit comments

Comments
 (0)