diff options
author | Rémy Coutable <remy@gitlab.com> | 2016-08-04 13:06:38 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-08-04 15:09:36 +0200 |
commit | 7c824b91cc8761e6463f1cc493894925b57faedf (patch) | |
tree | f55d2c31058f91994b694cd0b88b553343ab5e78 | |
parent | 9d69315d1b26da0eb5cf5738d0ce3f5cb02a6486 (diff) | |
download | gitlab-ce-7c824b91cc8761e6463f1cc493894925b57faedf.tar.gz |
Merge branch '20527-fork-commits-have-impact-on-original-project' into 'master'
Don’t close issues on original project
Closes #20527 -> https://gitlab.com/gitlab-org/gitlab-ce/issues/20527
See merge request !1981
Signed-off-by: Rémy Coutable <remy@rymai.me>
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | lib/gitlab/closing_issue_extractor.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/closing_issue_extractor_spec.rb | 11 |
3 files changed, 15 insertions, 1 deletions
diff --git a/CHANGELOG b/CHANGELOG index 30b40375cdf..8775b67ccd5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ Please view this file on the master branch, on stable branches it's out of date. v 8.10.4 (unreleased) + - Don't close referenced upstream issues from a forked project. v 8.10.3 - Fix Import/Export issue importing milestones and labels not associated properly. !5426 diff --git a/lib/gitlab/closing_issue_extractor.rb b/lib/gitlab/closing_issue_extractor.rb index 9bef9037ad6..58f86abc5c4 100644 --- a/lib/gitlab/closing_issue_extractor.rb +++ b/lib/gitlab/closing_issue_extractor.rb @@ -22,7 +22,9 @@ module Gitlab @extractor.analyze(closing_statements.join(" ")) - @extractor.issues + @extractor.issues.reject do |issue| + @extractor.project.forked_from?(issue.project) # Don't extract issues on original project + end end end end diff --git a/spec/lib/gitlab/closing_issue_extractor_spec.rb b/spec/lib/gitlab/closing_issue_extractor_spec.rb index e9b8ce6b5bb..de3f64249a2 100644 --- a/spec/lib/gitlab/closing_issue_extractor_spec.rb +++ b/spec/lib/gitlab/closing_issue_extractor_spec.rb @@ -3,10 +3,12 @@ require 'spec_helper' describe Gitlab::ClosingIssueExtractor, lib: true do let(:project) { create(:project) } let(:project2) { create(:project) } + let(:forked_project) { Projects::ForkService.new(project, project.creator).execute } let(:issue) { create(:issue, project: project) } let(:issue2) { create(:issue, project: project2) } let(:reference) { issue.to_reference } let(:cross_reference) { issue2.to_reference(project) } + let(:fork_cross_reference) { issue.to_reference(forked_project) } subject { described_class.new(project, project.creator) } @@ -278,6 +280,15 @@ describe Gitlab::ClosingIssueExtractor, lib: true do end end + context "with a cross-project fork reference" do + subject { described_class.new(forked_project, forked_project.creator) } + + it do + message = "Closes #{fork_cross_reference}" + expect(subject.closed_by_message(message)).to be_empty + end + end + context "with an invalid URL" do it do message = "Closes https://google.com#{urls.namespace_project_issue_path(issue2.project.namespace, issue2.project, issue2)}" |