diff options
author | Artem Sidorenko <artem@posteo.de> | 2016-09-14 00:05:16 +0300 |
---|---|---|
committer | Artem Sidorenko <artem@posteo.de> | 2016-10-11 11:50:49 +0300 |
commit | 6c1690fcc03406ad3230cb05ba8701289a25ba28 (patch) | |
tree | 0e6b894aaf956f0f48f9954de8a48ff38c107bdc /app/services/merge_requests/build_service.rb | |
parent | b26a3d538178c82d4e7af2076ba999087225666c (diff) |
Allow empty merge requests
Diffstat (limited to 'app/services/merge_requests/build_service.rb')
-rw-r--r-- | app/services/merge_requests/build_service.rb | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/app/services/merge_requests/build_service.rb b/app/services/merge_requests/build_service.rb index e57791f6818..404f75616b5 100644 --- a/app/services/merge_requests/build_service.rb +++ b/app/services/merge_requests/build_service.rb @@ -4,7 +4,7 @@ module MergeRequests merge_request = MergeRequest.new(params) # Set MR attributes - merge_request.can_be_created = false + merge_request.can_be_created = true merge_request.compare_commits = [] merge_request.source_project = project unless merge_request.source_project @@ -22,6 +22,12 @@ module MergeRequests return build_failed(merge_request, message) end + if merge_request.source_project == merge_request.target_project && + merge_request.target_branch == merge_request.source_branch + + return build_failed(merge_request, 'You must select different branches') + end + compare = CompareService.new.execute( merge_request.source_project, merge_request.source_branch, @@ -29,17 +35,8 @@ module MergeRequests merge_request.target_branch, ) - commits = compare.commits - - # At this point we decide if merge request can be created - # If we have at least one commit to merge -> creation allowed - if commits.present? - merge_request.compare_commits = commits - merge_request.can_be_created = true - merge_request.compare = compare - else - merge_request.can_be_created = false - end + merge_request.compare_commits = compare.commits + merge_request.compare = compare set_title_and_description(merge_request) end @@ -89,6 +86,8 @@ module MergeRequests end end + merge_request.title = merge_request.wip_title if commits.empty? + merge_request end |