mirror of
https://github.com/go-gitea/gitea
synced 2024-11-25 16:42:48 +01:00
Ensure executable bit is kept on the web editor (#10607)
Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
This commit is contained in:
parent
3d5d21133c
commit
4e65d2b8ea
1 changed files with 10 additions and 2 deletions
|
@ -230,6 +230,7 @@ func CreateOrUpdateRepoFile(repo *models.Repository, doer *models.User, opts *Up
|
||||||
|
|
||||||
encoding := "UTF-8"
|
encoding := "UTF-8"
|
||||||
bom := false
|
bom := false
|
||||||
|
executable := false
|
||||||
|
|
||||||
if !opts.IsNewFile {
|
if !opts.IsNewFile {
|
||||||
fromEntry, err := commit.GetTreeEntryByPath(fromTreePath)
|
fromEntry, err := commit.GetTreeEntryByPath(fromTreePath)
|
||||||
|
@ -265,6 +266,7 @@ func CreateOrUpdateRepoFile(repo *models.Repository, doer *models.User, opts *Up
|
||||||
return nil, models.ErrSHAOrCommitIDNotProvided{}
|
return nil, models.ErrSHAOrCommitIDNotProvided{}
|
||||||
}
|
}
|
||||||
encoding, bom = detectEncodingAndBOM(fromEntry, repo)
|
encoding, bom = detectEncodingAndBOM(fromEntry, repo)
|
||||||
|
executable = fromEntry.IsExecutable()
|
||||||
}
|
}
|
||||||
|
|
||||||
// For the path where this file will be created/updated, we need to make
|
// For the path where this file will be created/updated, we need to make
|
||||||
|
@ -388,9 +390,15 @@ func CreateOrUpdateRepoFile(repo *models.Repository, doer *models.User, opts *Up
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the object to the index
|
// Add the object to the index
|
||||||
|
if executable {
|
||||||
|
if err := t.AddObjectToIndex("100755", objectHash, treePath); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if err := t.AddObjectToIndex("100644", objectHash, treePath); err != nil {
|
if err := t.AddObjectToIndex("100644", objectHash, treePath); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Now write the tree
|
// Now write the tree
|
||||||
treeHash, err := t.WriteTree()
|
treeHash, err := t.WriteTree()
|
||||||
|
|
Loading…
Reference in a new issue