diff options
author | Rémy Coutable <remy@rymai.me> | 2016-04-13 09:10:57 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-04-13 09:10:57 +0000 |
commit | 8ea6c6d80c0942e0f2caee3caa0cd7503e51d45d (patch) | |
tree | db577bcf2a2bedadd069e152cb667848f4632833 /app | |
parent | 6bb71869b8c003e9e880646afa35050821e7dac9 (diff) | |
parent | a64f1c763615c049e551c82a9f3a7c53525a172c (diff) | |
download | gitlab-ce-8ea6c6d80c0942e0f2caee3caa0cd7503e51d45d.tar.gz |
Merge branch 'issue_15044' into 'master'
Allow to close invalid merge request
fixes #15044
See merge request !3664
Diffstat (limited to 'app')
-rw-r--r-- | app/models/commit.rb | 8 | ||||
-rw-r--r-- | app/models/merge_request.rb | 6 |
2 files changed, 8 insertions, 6 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb index d09876a07d9..11ecfcace14 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -150,13 +150,11 @@ class Commit end def hook_attrs(with_changed_files: false) - path_with_namespace = project.path_with_namespace - data = { id: id, message: safe_message, timestamp: committed_date.xmlschema, - url: "#{Gitlab.config.gitlab.url}/#{path_with_namespace}/commit/#{id}", + url: commit_url, author: { name: author_name, email: author_email @@ -170,6 +168,10 @@ class Commit data end + def commit_url + project.present? ? "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/commit/#{id}" : "" + end + # Discover issues should be closed when this commit is pushed to a project's # default branch. def closes_issues(current_user = self.committer) diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index bf185cb5dd8..e410febdfff 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -128,7 +128,7 @@ class MergeRequest < ActiveRecord::Base validates :target_project, presence: true validates :target_branch, presence: true validates :merge_user, presence: true, if: :merge_when_build_succeeds? - validate :validate_branches + validate :validate_branches, unless: :allow_broken validate :validate_fork scope :by_branch, ->(branch_name) { where("(source_branch LIKE :branch) OR (target_branch LIKE :branch)", branch: branch_name) } @@ -218,7 +218,7 @@ class MergeRequest < ActiveRecord::Base end if opened? || reopened? - similar_mrs = self.target_project.merge_requests.where(source_branch: source_branch, target_branch: target_branch, source_project_id: source_project.id).opened + similar_mrs = self.target_project.merge_requests.where(source_branch: source_branch, target_branch: target_branch, source_project_id: source_project.try(:id)).opened similar_mrs = similar_mrs.where('id not in (?)', self.id) if self.id if similar_mrs.any? errors.add :validate_branches, @@ -345,7 +345,7 @@ class MergeRequest < ActiveRecord::Base def hook_attrs attrs = { - source: source_project.hook_attrs, + source: source_project.try(:hook_attrs), target: target_project.hook_attrs, last_commit: nil, work_in_progress: work_in_progress? |