diff options
author | Antoine GIRARD <sapk@users.noreply.github.com> | 2020-03-05 00:46:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-05 00:46:12 +0100 |
commit | 4e65d2b8ea6347663cb7c67684f3297fd3f5f22e (patch) | |
tree | 2e137c1d0cb10b513939592e30f98df9c1bc8bd7 | |
parent | 3d5d21133ca93ab5ab4482bac11ca7c4fa21c407 (diff) | |
download | gitea-4e65d2b8ea6347663cb7c67684f3297fd3f5f22e.tar.gz gitea-4e65d2b8ea6347663cb7c67684f3297fd3f5f22e.zip |
Ensure executable bit is kept on the web editor (#10607)
Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
-rw-r--r-- | modules/repofiles/update.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/modules/repofiles/update.go b/modules/repofiles/update.go index 20b83655f5..4dfa4db0b1 100644 --- a/modules/repofiles/update.go +++ b/modules/repofiles/update.go @@ -230,6 +230,7 @@ func CreateOrUpdateRepoFile(repo *models.Repository, doer *models.User, opts *Up encoding := "UTF-8" bom := false + executable := false if !opts.IsNewFile { fromEntry, err := commit.GetTreeEntryByPath(fromTreePath) @@ -265,6 +266,7 @@ func CreateOrUpdateRepoFile(repo *models.Repository, doer *models.User, opts *Up return nil, models.ErrSHAOrCommitIDNotProvided{} } encoding, bom = detectEncodingAndBOM(fromEntry, repo) + executable = fromEntry.IsExecutable() } // 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 } // Add the object to the index - if err := t.AddObjectToIndex("100644", objectHash, treePath); err != nil { - return nil, err + if executable { + if err := t.AddObjectToIndex("100755", objectHash, treePath); err != nil { + return nil, err + } + } else { + if err := t.AddObjectToIndex("100644", objectHash, treePath); err != nil { + return nil, err + } } // Now write the tree |