diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-05-04 01:25:50 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-05-04 01:25:50 +0300 |
commit | 4faa65d8381f3e1e45bdf3a9bc9785b588891b66 (patch) | |
tree | 58eb65f24c3a0fa8a9e2ac502c97ea63c17954a7 /app/models/repository.rb | |
parent | 9604ce524f3ddc8d652f5611fb4c698746ef184d (diff) | |
parent | 268ec199da09f3d2c3e93b1f3546f2c3c89c48d0 (diff) |
Merge branch '31671-merge-request-message-contains-carriage-returns' into 'master'
removes the possibility of commit messages having carriage returns
Closes #31671
See merge request !11077
Diffstat (limited to 'app/models/repository.rb')
-rw-r--r-- | app/models/repository.rb | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index ba34d570dbd..0c797dd5814 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -789,7 +789,7 @@ class Repository } options.merge!(get_committer_and_author(user, email: author_email, name: author_name)) - Rugged::Commit.create(rugged, options) + create_commit(options) end end # rubocop:enable Metrics/ParameterLists @@ -836,7 +836,7 @@ class Repository tree: merge_index.write_tree(rugged), ) - commit_id = Rugged::Commit.create(rugged, actual_options) + commit_id = create_commit(actual_options) merge_request.update(in_progress_merge_commit_sha: commit_id) commit_id end @@ -859,12 +859,11 @@ class Repository committer = user_to_committer(user) - Rugged::Commit.create(rugged, - message: commit.revert_message(user), - author: committer, - committer: committer, - tree: revert_tree_id, - parents: [start_commit.sha]) + create_commit(message: commit.revert_message(user), + author: committer, + committer: committer, + tree: revert_tree_id, + parents: [start_commit.sha]) end end @@ -883,16 +882,15 @@ class Repository committer = user_to_committer(user) - Rugged::Commit.create(rugged, - message: commit.message, - author: { - email: commit.author_email, - name: commit.author_name, - time: commit.authored_date - }, - committer: committer, - tree: cherry_pick_tree_id, - parents: [start_commit.sha]) + create_commit(message: commit.message, + author: { + email: commit.author_email, + name: commit.author_name, + time: commit.authored_date + }, + committer: committer, + tree: cherry_pick_tree_id, + parents: [start_commit.sha]) end end @@ -900,7 +898,7 @@ class Repository GitOperationService.new(user, self).with_branch(branch_name) do committer = user_to_committer(user) - Rugged::Commit.create(rugged, params.merge(author: committer, committer: committer)) + create_commit(params.merge(author: committer, committer: committer)) end end @@ -1142,6 +1140,12 @@ class Repository Gitlab::Metrics.add_event(event, { path: path_with_namespace }.merge(tags)) end + def create_commit(params = {}) + params[:message].delete!("\r") + + Rugged::Commit.create(rugged, params) + end + def repository_storage_path @project.repository_storage_path end |