diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example index ddee467b14b7de5cfabfe076fdab6851be3eae81..35c7c425a5a75999bae5fd14c28cea605337c9fa 100644 --- a/config/gitlab.yml.example +++ b/config/gitlab.yml.example @@ -80,7 +80,7 @@ production: &base # This happens when the commit is pushed or merged into the default branch of a project. # When not specified the default issue_closing_pattern as specified below will be used. # Tip: you can test your closing pattern at http://rubular.com. - # issue_closing_pattern: '((?:[Cc]los(?:e[sd]?|ing)|[Ff]ix(?:e[sd]|ing)?) +(?:(?:issues? +)?%{issue_ref}(?:(?:, *| +and +)?))+)' + # issue_closing_pattern: '((?:[Cc]los(?:e[sd]?|ing)|[Ff]ix(?:e[sd]|ing)?|[Rr]esolv(?:e[sd]?|ing))(:?) +(?:(?:issues? +)?%{issue_ref}(?:(?:, *| +and +)?)|([A-Z][A-Z0-9_]+-\d+))+)' ## Default project features settings default_projects_features: diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index 8488482e4abec868d6516c863cf1716f18499ee6..72c4d8d61ced7f7a9ee85d6f1d7481133334ada8 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -177,7 +177,6 @@ Settings.gitlab['signin_enabled'] ||= true if Settings.gitlab['signin_enabled']. Settings.gitlab['restricted_visibility_levels'] = Settings.send(:verify_constant_array, Gitlab::VisibilityLevel, Settings.gitlab['restricted_visibility_levels'], []) Settings.gitlab['username_changing_enabled'] = true if Settings.gitlab['username_changing_enabled'].nil? Settings.gitlab['issue_closing_pattern'] = '((?:[Cc]los(?:e[sd]?|ing)|[Ff]ix(?:e[sd]|ing)?|[Rr]esolv(?:e[sd]?|ing))(:?) +(?:(?:issues? +)?%{issue_ref}(?:(?:, *| +and +)?)|([A-Z][A-Z0-9_]+-\d+))+)' if Settings.gitlab['issue_closing_pattern'].nil? -puts Settings.gitlab['issue_closing_pattern'] Settings.gitlab['default_projects_features'] ||= {} Settings.gitlab['webhook_timeout'] ||= 10 Settings.gitlab['max_attachment_size'] ||= 10 diff --git a/spec/lib/gitlab/closing_issue_extractor_spec.rb b/spec/lib/gitlab/closing_issue_extractor_spec.rb index a1f51429a79b117395df3b28c445d104cb1b1fc0..e9b8ce6b5bb184523eb0f03d8c12b339ed13ff5f 100644 --- a/spec/lib/gitlab/closing_issue_extractor_spec.rb +++ b/spec/lib/gitlab/closing_issue_extractor_spec.rb @@ -22,11 +22,21 @@ describe Gitlab::ClosingIssueExtractor, lib: true do expect(subject.closed_by_message(message)).to eq([issue]) end + it do + message = "Awesome commit (Closes: #{reference})" + expect(subject.closed_by_message(message)).to eq([issue]) + end + it do message = "Awesome commit (closes #{reference})" expect(subject.closed_by_message(message)).to eq([issue]) end + it do + message = "Awesome commit (closes: #{reference})" + expect(subject.closed_by_message(message)).to eq([issue]) + end + it do message = "Closed #{reference}" expect(subject.closed_by_message(message)).to eq([issue]) @@ -37,106 +47,211 @@ describe Gitlab::ClosingIssueExtractor, lib: true do expect(subject.closed_by_message(message)).to eq([issue]) end + it do + message = "closed: #{reference}" + expect(subject.closed_by_message(message)).to eq([issue]) + end + it do message = "Closing #{reference}" expect(subject.closed_by_message(message)).to eq([issue]) end + it do + message = "Closing: #{reference}" + expect(subject.closed_by_message(message)).to eq([issue]) + end + it do message = "closing #{reference}" expect(subject.closed_by_message(message)).to eq([issue]) end + it do + message = "closing: #{reference}" + expect(subject.closed_by_message(message)).to eq([issue]) + end + it do message = "Close #{reference}" expect(subject.closed_by_message(message)).to eq([issue]) end + it do + message = "Close: #{reference}" + expect(subject.closed_by_message(message)).to eq([issue]) + end + it do message = "close #{reference}" expect(subject.closed_by_message(message)).to eq([issue]) end + it do + message = "close: #{reference}" + expect(subject.closed_by_message(message)).to eq([issue]) + end + it do message = "Awesome commit (Fixes #{reference})" expect(subject.closed_by_message(message)).to eq([issue]) end + it do + message = "Awesome commit (Fixes: #{reference})" + expect(subject.closed_by_message(message)).to eq([issue]) + end + it do message = "Awesome commit (fixes #{reference})" expect(subject.closed_by_message(message)).to eq([issue]) end + it do + message = "Awesome commit (Fixes: #{reference})" + expect(subject.closed_by_message(message)).to eq([issue]) + end + it do message = "Fixed #{reference}" expect(subject.closed_by_message(message)).to eq([issue]) end + it do + message = "Fixed: #{reference}" + expect(subject.closed_by_message(message)).to eq([issue]) + end + it do message = "fixed #{reference}" expect(subject.closed_by_message(message)).to eq([issue]) end + it do + message = "fixed: #{reference}" + expect(subject.closed_by_message(message)).to eq([issue]) + end + it do message = "Fixing #{reference}" expect(subject.closed_by_message(message)).to eq([issue]) end + it do + message = "Fixing: #{reference}" + expect(subject.closed_by_message(message)).to eq([issue]) + end + it do message = "fixing #{reference}" expect(subject.closed_by_message(message)).to eq([issue]) end + it do + message = "fixing: #{reference}" + expect(subject.closed_by_message(message)).to eq([issue]) + end + it do message = "Fix #{reference}" expect(subject.closed_by_message(message)).to eq([issue]) end + it do + message = "Fix: #{reference}" + expect(subject.closed_by_message(message)).to eq([issue]) + end + it do message = "fix #{reference}" expect(subject.closed_by_message(message)).to eq([issue]) end + it do + message = "fix: #{reference}" + expect(subject.closed_by_message(message)).to eq([issue]) + end + it do message = "Awesome commit (Resolves #{reference})" expect(subject.closed_by_message(message)).to eq([issue]) end + it do + message = "Awesome commit (Resolves: #{reference})" + expect(subject.closed_by_message(message)).to eq([issue]) + end + it do message = "Awesome commit (resolves #{reference})" expect(subject.closed_by_message(message)).to eq([issue]) end + it do + message = "Awesome commit (resolves: #{reference})" + expect(subject.closed_by_message(message)).to eq([issue]) + end + it do message = "Resolved #{reference}" expect(subject.closed_by_message(message)).to eq([issue]) end + it do + message = "Resolved: #{reference}" + expect(subject.closed_by_message(message)).to eq([issue]) + end + it do message = "resolved #{reference}" expect(subject.closed_by_message(message)).to eq([issue]) end + it do + message = "resolved: #{reference}" + expect(subject.closed_by_message(message)).to eq([issue]) + end + it do message = "Resolving #{reference}" expect(subject.closed_by_message(message)).to eq([issue]) end + it do + message = "Resolving: #{reference}" + expect(subject.closed_by_message(message)).to eq([issue]) + end + it do message = "resolving #{reference}" expect(subject.closed_by_message(message)).to eq([issue]) end + it do + message = "resolving: #{reference}" + expect(subject.closed_by_message(message)).to eq([issue]) + end + it do message = "Resolve #{reference}" expect(subject.closed_by_message(message)).to eq([issue]) end + it do + message = "Resolve: #{reference}" + expect(subject.closed_by_message(message)).to eq([issue]) + end + it do message = "resolve #{reference}" expect(subject.closed_by_message(message)).to eq([issue]) end + it do + message = "resolve: #{reference}" + expect(subject.closed_by_message(message)).to eq([issue]) + end + context 'with an external issue tracker reference' do it 'extracts the referenced issue' do jira_project = create(:jira_project, name: 'JIRA_EXT1')