summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2017-09-05 12:46:55 +0000
committerSean McGivern <sean@mcgivern.me.uk>2017-09-05 12:46:55 +0000
commit75d56cec1bb28af32f471d6ba39e09216bcad3ce (patch)
tree1e39bfe56df88adf7be5ab862328c5a91adf72c9 /lib
parentd4d3acd7637cddea786e521c5689a1a303453ea9 (diff)
parent9d88ad45d2d60b390e697097f0184d79aac4a8eb (diff)
downloadgitlab-ce-75d56cec1bb28af32f471d6ba39e09216bcad3ce.tar.gz
Merge branch 'move-operation-service-call-sites' into 'master'
Add Gitaly migration points for branch/tag create/delete See merge request !13993
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/git/repository.rb43
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb
index c67f7724307..f7577b02d5d 100644
--- a/lib/gitlab/git/repository.rb
+++ b/lib/gitlab/git/repository.rb
@@ -605,6 +605,49 @@ module Gitlab
# TODO: implement this method
end
+ def add_branch(branch_name, committer:, target:)
+ target_object = Ref.dereference_object(lookup(target))
+ raise InvalidRef.new("target not found: #{target}") unless target_object
+
+ OperationService.new(committer, self).add_branch(branch_name, target_object.oid)
+ find_branch(branch_name)
+ rescue Rugged::ReferenceError => ex
+ raise InvalidRef, ex
+ end
+
+ def add_tag(tag_name, committer:, target:, message: nil)
+ target_object = Ref.dereference_object(lookup(target))
+ raise InvalidRef.new("target not found: #{target}") unless target_object
+
+ committer = Committer.from_user(committer) if committer.is_a?(User)
+
+ options = nil # Use nil, not the empty hash. Rugged cares about this.
+ if message
+ options = {
+ message: message,
+ tagger: Gitlab::Git.committer_hash(email: committer.email, name: committer.name)
+ }
+ end
+
+ OperationService.new(committer, self).add_tag(tag_name, target_object.oid, options)
+
+ find_tag(tag_name)
+ rescue Rugged::ReferenceError => ex
+ raise InvalidRef, ex
+ end
+
+ def rm_branch(branch_name, committer:)
+ OperationService.new(committer, self).rm_branch(find_branch(branch_name))
+ end
+
+ def rm_tag(tag_name, committer:)
+ OperationService.new(committer, self).rm_tag(find_tag(tag_name))
+ end
+
+ def find_tag(name)
+ tags.find { |tag| tag.name == name }
+ end
+
# Delete the specified branch from the repository
#
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/476