summaryrefslogtreecommitdiff
path: root/app/models/repository.rb
diff options
context:
space:
mode:
authorTiago Botelho <tiagonbotelho@hotmail.com>2017-05-03 18:37:34 +0100
committerTiago Botelho <tiagonbotelho@hotmail.com>2017-05-03 21:25:57 +0100
commit268ec199da09f3d2c3e93b1f3546f2c3c89c48d0 (patch)
treec92d198186f7606279d17321d99d284c944ce714 /app/models/repository.rb
parent3ff8d8020e495df319f0b0921bc94b1c3470f6f0 (diff)
downloadgitlab-ce-268ec199da09f3d2c3e93b1f3546f2c3c89c48d0.tar.gz
removes the possibility of commit messages having carriage returns
Diffstat (limited to 'app/models/repository.rb')
-rw-r--r--app/models/repository.rb42
1 files changed, 23 insertions, 19 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 7bb874d7744..8fde23ad4f9 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -791,7 +791,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
@@ -838,7 +838,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
@@ -861,12 +861,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
@@ -885,16 +884,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
@@ -902,7 +900,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
@@ -1146,6 +1144,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