summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorRubén Dávila <ruben@gitlab.com>2015-12-03 22:48:08 -0500
committerRobert Speicher <rspeicher@gmail.com>2016-02-19 13:14:48 -0500
commitd7511a4b04f89a29057dbab2f5e3500fad4e5c18 (patch)
tree11dd2d71de32513145610aa1b76e72e8381f344a /app/models
parentd3c243732869ca927406020bc5088b1931e4dc0c (diff)
downloadgitlab-ce-d7511a4b04f89a29057dbab2f5e3500fad4e5c18.tar.gz
Create reverse branch and generate MR with new branch. #3409
Diffstat (limited to 'app/models')
-rw-r--r--app/models/merge_request.rb4
-rw-r--r--app/models/repository.rb4
2 files changed, 8 insertions, 0 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index ea2b0e075f6..a7dd715a303 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -532,4 +532,8 @@ class MergeRequest < ActiveRecord::Base
[diff_base_commit, last_commit]
end
+
+ def reverse_branch_name
+ "revert-#{id}-#{target_branch}"
+ end
end
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 73aa67d46ec..1463446bcc2 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -137,6 +137,10 @@ class Repository
find_branch(branch_name)
end
+ def find_or_create_branch(name, ref)
+ find_branch(name) or add_branch(name, ref)
+ end
+
def add_tag(tag_name, ref, message = nil)
expire_tags_cache