summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Vosmaer <jacob@gitlab.com>2017-08-24 14:05:24 +0200
committerJacob Vosmaer <jacob@gitlab.com>2017-08-24 14:05:24 +0200
commita1a914994f6376b03d95e9d4b05dea422e8610f9 (patch)
treec8ea02e27ed2133777b8ea88ea1143655ca41b67
parent961da7d0a7024628ec87c02c158a147dd64b3317 (diff)
downloadgitlab-ce-git-operation-user.tar.gz
Avoid committer = linesgit-operation-user
-rw-r--r--app/models/repository.rb27
-rw-r--r--app/services/git_operation_service.rb5
2 files changed, 11 insertions, 21 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 062f532233f..59f913c7fb4 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -164,8 +164,7 @@ class Repository
return false unless newrev
- committer = Gitlab::Git::Committer.from_user(user)
- GitOperationService.new(committer, self).add_branch(branch_name, newrev)
+ GitOperationService.new(user, self).add_branch(branch_name, newrev)
after_create_branch
find_branch(branch_name)
@@ -177,8 +176,7 @@ class Repository
return false unless newrev
- committer = Gitlab::Git::Committer.from_user(user)
- GitOperationService.new(committer, self).add_tag(tag_name, newrev, options)
+ GitOperationService.new(user, self).add_tag(tag_name, newrev, options)
find_tag(tag_name)
end
@@ -187,8 +185,7 @@ class Repository
before_remove_branch
branch = find_branch(branch_name)
- committer = Gitlab::Git::Committer.from_user(user)
- GitOperationService.new(committer, self).rm_branch(branch)
+ GitOperationService.new(user, self).rm_branch(branch)
after_remove_branch
true
@@ -198,8 +195,7 @@ class Repository
before_remove_tag
tag = find_tag(tag_name)
- committer = Gitlab::Git::Committer.from_user(user)
- GitOperationService.new(committer, self).rm_tag(tag)
+ GitOperationService.new(user, self).rm_tag(tag)
after_remove_tag
true
@@ -767,8 +763,7 @@ class Repository
author_email: nil, author_name: nil,
start_branch_name: nil, start_project: project)
- committer = Gitlab::Git::Committer.from_user(user)
- GitOperationService.new(committer, self).with_branch(
+ GitOperationService.new(user, self).with_branch(
branch_name,
start_branch_name: start_branch_name,
start_project: start_project) do |start_commit|
@@ -824,8 +819,7 @@ class Repository
end
def merge(user, source, merge_request, options = {})
- committer = Gitlab::Git::Committer.from_user(user)
- GitOperationService.new(committer, self).with_branch(
+ GitOperationService.new(user, self).with_branch(
merge_request.target_branch) do |start_commit|
our_commit = start_commit.sha
their_commit = source
@@ -852,8 +846,7 @@ class Repository
def revert(
user, commit, branch_name,
start_branch_name: nil, start_project: project)
- committer = Gitlab::Git::Committer.from_user(user)
- GitOperationService.new(committer, self).with_branch(
+ GitOperationService.new(user, self).with_branch(
branch_name,
start_branch_name: start_branch_name,
start_project: start_project) do |start_commit|
@@ -876,8 +869,7 @@ class Repository
def cherry_pick(
user, commit, branch_name,
start_branch_name: nil, start_project: project)
- committer = Gitlab::Git::Committer.from_user(user)
- GitOperationService.new(committer, self).with_branch(
+ GitOperationService.new(user, self).with_branch(
branch_name,
start_branch_name: start_branch_name,
start_project: start_project) do |start_commit|
@@ -902,8 +894,7 @@ class Repository
end
def resolve_conflicts(user, branch_name, params)
- committer = Gitlab::Git::Committer.from_user(user)
- GitOperationService.new(committer, self).with_branch(branch_name) do
+ GitOperationService.new(user, self).with_branch(branch_name) do
committer = user_to_committer(user)
create_commit(params.merge(author: committer, committer: committer))
diff --git a/app/services/git_operation_service.rb b/app/services/git_operation_service.rb
index 6a983566526..6b7a56e6922 100644
--- a/app/services/git_operation_service.rb
+++ b/app/services/git_operation_service.rb
@@ -2,10 +2,9 @@ class GitOperationService
attr_reader :committer, :repository
def initialize(committer, new_repository)
- if committer && !committer.is_a?(Gitlab::Git::Committer)
- raise "expected Gitlab::Git::Committer, got #{committer.inspect}"
- end
+ committer = Gitlab::Git::Committer.from_user(committer) if committer.is_a?(User)
@committer = committer
+
@repository = new_repository
end