changeset 1837:a6a30c919513 beta

#73 mapping of commited issues from commit message into issue tracker url.
author Marcin Kuzminski <marcin@python-works.com>
date Fri, 06 Jan 2012 19:27:32 +0200
parents 445861e156d1
children 2ef309c3175d
files development.ini production.ini rhodecode/config/deployment.ini_tmpl rhodecode/lib/helpers.py rhodecode/public/css/style.css rhodecode/templates/changelog/changelog.html rhodecode/templates/changeset/changeset.html rhodecode/templates/changeset/changeset_range.html rhodecode/templates/shortlog/shortlog_data.html
diffstat 9 files changed, 122 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/development.ini	Fri Jan 06 06:39:54 2012 +0200
+++ b/development.ini	Fri Jan 06 19:27:32 2012 +0200
@@ -58,13 +58,34 @@
 proxypass_auth_enabled = false
 
 ## overwrite schema of clone url
-# available vars:
-# scheme - http/https
-# user - current user
-# pass - password 
-# netloc - network location
-# path - usually repo_name
-# clone_uri = {scheme}://{user}{pass}{netloc}{path}
+## available vars:
+## scheme - http/https
+## user - current user
+## pass - password 
+## netloc - network location
+## path - usually repo_name
+
+#clone_uri = {scheme}://{user}{pass}{netloc}{path}
+
+## issue tracking mapping for commits messages
+## uncomment url_pat, issue_server, issue_prefix to enable
+
+
+## pattern to get the issues from commit messages
+## default one used here is #1234
+
+#url_pat = (?:^#|\s#)(\w+)
+
+## server url to the issue, each {id} will be replaced with id
+## fetched from the regex
+
+#issue_server = https://myissueserver.com/issue/{id}
+
+## prefix to add to link to indicate it's an url
+## #314 will be replaced by <issue_prefix><id>
+
+#issue_prefix = #
+
 
 ####################################
 ###        CELERY CONFIG        ####
--- a/production.ini	Fri Jan 06 06:39:54 2012 +0200
+++ b/production.ini	Fri Jan 06 19:27:32 2012 +0200
@@ -58,13 +58,34 @@
 proxypass_auth_enabled = false
 
 ## overwrite schema of clone url
-# available vars:
-# scheme - http/https
-# user - current user
-# pass - password 
-# netloc - network location
-# path - usually repo_name
-# clone_uri = {scheme}://{user}{pass}{netloc}{path}
+## available vars:
+## scheme - http/https
+## user - current user
+## pass - password 
+## netloc - network location
+## path - usually repo_name
+
+#clone_uri = {scheme}://{user}{pass}{netloc}{path}
+
+## issue tracking mapping for commits messages
+## uncomment url_pat, issue_server, issue_prefix to enable
+
+
+## pattern to get the issues from commit messages
+## default one used here is #1234
+
+#url_pat = (?:^#|\s#)(\w+)
+
+## server url to the issue, each {id} will be replaced with id
+## fetched from the regex
+
+#issue_server = https://myissueserver.com/issue/{id}
+
+## prefix to add to link to indicate it's an url
+## #314 will be replaced by <issue_prefix><id>
+
+#issue_prefix = #
+
 
 ####################################
 ###        CELERY CONFIG        ####
--- a/rhodecode/config/deployment.ini_tmpl	Fri Jan 06 06:39:54 2012 +0200
+++ b/rhodecode/config/deployment.ini_tmpl	Fri Jan 06 19:27:32 2012 +0200
@@ -58,14 +58,35 @@
 proxypass_auth_enabled = false
 
 ## overwrite schema of clone url
-# available vars:
-# scheme - http/https
-# user - current user
-# pass - password 
-# netloc - network location
-# path - usually repo_name
+## available vars:
+## scheme - http/https
+## user - current user
+## pass - password 
+## netloc - network location
+## path - usually repo_name
+
 # clone_uri = {scheme}://{user}{pass}{netloc}{path}
 
+## issue tracking mapping for commits messages
+## uncomment url_pat, issue_server, issue_prefix to enable
+
+
+## pattern to get the issues from commit messages
+## default one used here is #1234
+
+#url_pat = (?:^#|\s#)(\w+)
+
+## server url to the issue, each {id} will be replaced with id
+## fetched from the regex
+
+#issue_server = https://myissueserver.com/issue/{id}
+
+## prefix to add to link to indicate it's an url
+## #314 will be replaced by <issue_prefix><id>
+
+#issue_prefix = #
+
+
 ####################################
 ###        CELERY CONFIG        ####
 ####################################
--- a/rhodecode/lib/helpers.py	Fri Jan 06 06:39:54 2012 +0200
+++ b/rhodecode/lib/helpers.py	Fri Jan 06 19:27:32 2012 +0200
@@ -8,6 +8,7 @@
 import StringIO
 import urllib
 import math
+import logging
 
 from datetime import datetime
 from pygments.formatters.html import HtmlFormatter
@@ -41,6 +42,8 @@
 from rhodecode.lib import str2bool, safe_unicode, safe_str, get_changeset_safe
 from rhodecode.lib.markup_renderer import MarkupRenderer
 
+log = logging.getLogger(__name__)
+
 
 def _reset(name, value=None, id=NotGiven, type="reset", **attrs):
     """
@@ -740,6 +743,33 @@
 
     return literal(url_pat.sub(url_func, text))
 
+def urlify_commit(text):
+    import re
+    import traceback
+    
+    try:
+        conf = config['app_conf']
+        
+        URL_PAT = re.compile(r'%s' % conf.get('url_pat'))
+        
+        if URL_PAT:
+            ISSUE_SERVER = conf.get('issue_server')
+            ISSUE_PREFIX = conf.get('issue_prefix')
+            def url_func(match_obj):
+                issue_id = match_obj.groups()[0]
+                return ' <a href="%(url)s">%(issue-prefix)s%(id-repr)s</a>' % (
+                    {'url':ISSUE_SERVER.replace('{id}',issue_id),
+                     'id-repr':issue_id,
+                     'issue-prefix':ISSUE_PREFIX,
+                     'serv':ISSUE_SERVER,
+                    }
+                )
+            return literal(URL_PAT.sub(url_func, text))
+    except:
+        log.error(traceback.format_exc())
+        pass
+
+    return text
 
 def rst(source):
     return literal('<div class="rst-block">%s</div>' %
--- a/rhodecode/public/css/style.css	Fri Jan 06 06:39:54 2012 +0200
+++ b/rhodecode/public/css/style.css	Fri Jan 06 19:27:32 2012 +0200
@@ -2146,8 +2146,6 @@
 }
 
 #changeset_content .container .left .message {
-	font-style: italic;
-	color: #556CB5;
 	white-space: pre-wrap;
 }
 #changeset_content .container .left .message a:hover {
--- a/rhodecode/templates/changelog/changelog.html	Fri Jan 06 06:39:54 2012 +0200
+++ b/rhodecode/templates/changelog/changelog.html	Fri Jan 06 19:27:32 2012 +0200
@@ -48,7 +48,7 @@
 						<div class="left">
 							<div class="date">
 							${h.checkbox(cs.short_id,class_="changeset_range")}
-							<span>${_('commit')} ${cs.revision}: ${h.short_id(cs.raw_id)}@${cs.date}</span>
+							<span class="tooltip" title="${cs.date}"><a href="${h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id)}">${cs.revision}:${h.short_id(cs.raw_id)}</a></span>
 							</div>
 							<div class="author">
 								<div class="gravatar">
@@ -56,7 +56,7 @@
 								</div>
 								<div title="${cs.author}" class="user">${h.person(cs.author)}</div>
 							</div>
-							<div class="message">${h.link_to(h.wrap_paragraphs(cs.message),h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id))}</div>
+							<div class="message">${h.urlify_commit(h.wrap_paragraphs(cs.message))}</div>
 						</div>	
 						<div class="right">
 									<div id="${cs.raw_id}_changes_info" class="changes">
--- a/rhodecode/templates/changeset/changeset.html	Fri Jan 06 06:39:54 2012 +0200
+++ b/rhodecode/templates/changeset/changeset.html	Fri Jan 06 19:27:32 2012 +0200
@@ -52,7 +52,7 @@
 	                     <span>${h.person(c.changeset.author)}</span><br/>
 	                     <span><a href="mailto:${h.email_or_none(c.changeset.author)}">${h.email_or_none(c.changeset.author)}</a></span><br/>
 	                 </div>
-	                 <div class="message">${h.link_to(h.wrap_paragraphs(c.changeset.message),h.url('changeset_home',repo_name=c.repo_name,revision=c.changeset.raw_id))}</div>
+	                 <div class="message">${h.urlify_commit(h.wrap_paragraphs(c.changeset.message))}</div>
 	             </div>
 	             <div class="right">
 		             <div class="changes">
--- a/rhodecode/templates/changeset/changeset_range.html	Fri Jan 06 06:39:54 2012 +0200
+++ b/rhodecode/templates/changeset/changeset_range.html	Fri Jan 06 19:27:32 2012 +0200
@@ -41,7 +41,7 @@
                 <td>${h.link_to('r%s:%s' % (cs.revision,h.short_id(cs.raw_id)),h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id))}</td>
                 <td><div class="author">${h.person(cs.author)}</div></td>
                 <td><span class="tooltip" title="${h.age(cs.date)}">${cs.date}</span></td>
-                <td><div class="message">${h.link_to(h.wrap_paragraphs(cs.message),h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id))}</div></td>
+                <td><div class="message">${h.urlify_commit(h.wrap_paragraphs(c.changeset.message))}</div></td>
                 </tr>
             %endfor
             </table>
--- a/rhodecode/templates/shortlog/shortlog_data.html	Fri Jan 06 06:39:54 2012 +0200
+++ b/rhodecode/templates/shortlog/shortlog_data.html	Fri Jan 06 19:27:32 2012 +0200
@@ -2,16 +2,19 @@
 %if c.repo_changesets:
 <table class="table_disp">
 	<tr>
-		<th class="left">${_('commit message')}</th>
+	    <th class="left">${_('revision')}</th>	
+        <th class="left">${_('commit message')}</th>
 		<th class="left">${_('age')}</th>
 		<th class="left">${_('author')}</th>
-		<th class="left">${_('revision')}</th>
 		<th class="left">${_('branch')}</th>
 		<th class="left">${_('tags')}</th>
 	</tr>
 %for cnt,cs in enumerate(c.repo_changesets):
 	<tr class="parity${cnt%2}">
         <td>
+            <div><pre><a href="${h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id)}">r${cs.revision}:${h.short_id(cs.raw_id)}</a></pre></div>
+        </td>  
+        <td>
             ${h.link_to(h.truncate(cs.message,50),
             h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id),
             title=cs.message)}
@@ -20,7 +23,6 @@
                       ${h.age(cs.date)}</span>
         </td>        	
 		<td title="${cs.author}">${h.person(cs.author)}</td>
-		<td><div><pre><a href="${h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id)}">r${cs.revision}:${h.short_id(cs.raw_id)}</a></pre></div></td>
 		<td>
 			<span class="logtags">
 				<span class="branchtag">${cs.branch}</span>