From c99f42ce71b5bd8351df987f63fcd7d35c843296 Mon Sep 17 00:00:00 2001 From: Max Wippert Date: Thu, 7 Aug 2014 15:19:14 +0200 Subject: [PATCH] fixed redmine<->gitlab integration - when a proect configures "Lightweight issue tracking system for this project" to be "Issues tracker" = "Redmine", Wiki-Markdown text like "lorem ipsum #123" should be rendered to a hyperlink to Redmine - without this patch/enhancment this did not work - internal bugtracker id = redmine 16693 --- app/models/project.rb | 4 ++++ lib/gitlab/markdown.rb | 17 +++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index a2247ba1d4..799c405653 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -338,6 +338,10 @@ class Project < ActiveRecord::Base self.issues_tracker == "jira" end + def redmine_tracker? + self.issues_tracker == "redmine" + end + # For compatibility with old code def code path diff --git a/lib/gitlab/markdown.rb b/lib/gitlab/markdown.rb index aee98ce36f..c30a47d6ae 100644 --- a/lib/gitlab/markdown.rb +++ b/lib/gitlab/markdown.rb @@ -192,8 +192,10 @@ module Gitlab link_to("##{identifier}", url, options) end - else - reference_jira_issue(identifier, project) if project.jira_tracker? + elsif project.redmine_tracker? + reference_redmine_issue(identifier, project) + elsif project.jira_tracker? + reference_jira_issue(identifier, project) end end @@ -239,5 +241,16 @@ module Gitlab ) link_to("#{identifier}", url, options) end + + def reference_redmine_issue(identifier, project = @project) + url = url_for_issue(identifier) + title = Gitlab.config.issues_tracker[project.issues_tracker]["title"] + + options = html_options.merge( + title: "Issue in #{title}", + class: "gfm gfm-issue #{html_options[:class]}" + ) + link_to("rm##{identifier}", url, options) + end end end