Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure executable bit is kept on the web editor #10607

Merged
merged 2 commits into from
Mar 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions modules/repofiles/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down