From 5ec3129ea657dc1c28c45ed4f54ec62fc6050ce6 Mon Sep 17 00:00:00 2001
From: Pedro Guridi <pedro.guridi@gmail.com>
Date: Mon, 27 May 2013 11:53:50 -0300
Subject: [PATCH] Changed regex to support Jira issue numbering format

Jira issues numbering format are like: "PROJECT-1234".
Changed the regular expression to support Jira issues linking, in addition to the normal #123.

Added Jira Issue tracker configuration example
---
 config/gitlab.yml.example | 5 +++++
 lib/gitlab/markdown.rb    | 3 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example
index e5fac336a44..a612102ab1c 100644
--- a/config/gitlab.yml.example
+++ b/config/gitlab.yml.example
@@ -70,6 +70,11 @@ production: &base
     #   ##  :project_id        - GitLab project identifier
     #   ##  :issues_tracker_id - Project Name or Id in external issue tracker
     #   new_issue_url: "http://redmine.sample/projects/:issues_tracker_id/issues/new"
+    # 
+    # jira:
+    #   project_url: "http://jira.sample/issues/?jql=project=:issues_tracker_id"
+    #   issues_url: "http://jira.sample/browse/:id"
+    #   new_issue_url: "http://jira.sample/secure/CreateIssue.jspa"
 
   ## Gravatar
   gravatar:
diff --git a/lib/gitlab/markdown.rb b/lib/gitlab/markdown.rb
index 92c9327070b..cea026f6182 100644
--- a/lib/gitlab/markdown.rb
+++ b/lib/gitlab/markdown.rb
@@ -7,6 +7,7 @@ module Gitlab
   # Supported reference formats are:
   #   * @foo for team members
   #   * #123 for issues
+  #   * #JIRA-123 for Jira issues
   #   * !123 for merge requests
   #   * $123 for snippets
   #   * 123456 for commits
@@ -97,7 +98,7 @@ module Gitlab
       (?<prefix>\W)?                         # Prefix
       (                                      # Reference
          @(?<user>[a-zA-Z][a-zA-Z0-9_\-\.]*) # User name
-        |\#(?<issue>\d+)                     # Issue ID
+        |\#(?<issue>([a-zA-Z]+-)?\d+)        # Issue ID
         |!(?<merge_request>\d+)              # MR ID
         |\$(?<snippet>\d+)                   # Snippet ID
         |(?<commit>[\h]{6,40})               # Commit ID
-- 
2.30.9