Skip to content

Commit 4e65d2b

Browse files
authored
Ensure executable bit is kept on the web editor (#10607)
Co-authored-by: Antoine GIRARD <[email protected]>
1 parent 3d5d211 commit 4e65d2b

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
@@ -230,6 +230,7 @@ func CreateOrUpdateRepoFile(repo *models.Repository, doer *models.User, opts *Up
230230

231231
encoding := "UTF-8"
232232
bom := false
233+
executable := false
233234

234235
if !opts.IsNewFile {
235236
fromEntry, err := commit.GetTreeEntryByPath(fromTreePath)
@@ -265,6 +266,7 @@ func CreateOrUpdateRepoFile(repo *models.Repository, doer *models.User, opts *Up
265266
return nil, models.ErrSHAOrCommitIDNotProvided{}
266267
}
267268
encoding, bom = detectEncodingAndBOM(fromEntry, repo)
269+
executable = fromEntry.IsExecutable()
268270
}
269271

270272
// For the path where this file will be created/updated, we need to make
@@ -388,8 +390,14 @@ func CreateOrUpdateRepoFile(repo *models.Repository, doer *models.User, opts *Up
388390
}
389391

390392
// Add the object to the index
391-
if err := t.AddObjectToIndex("100644", objectHash, treePath); err != nil {
392-
return nil, err
393+
if executable {
394+
if err := t.AddObjectToIndex("100755", objectHash, treePath); err != nil {
395+
return nil, err
396+
}
397+
} else {
398+
if err := t.AddObjectToIndex("100644", objectHash, treePath); err != nil {
399+
return nil, err
400+
}
393401
}
394402

395403
// Now write the tree

0 commit comments

Comments
 (0)