KisssPM
  • Overview
  • Repository
  • Tickets
  • Statistics
  • Credits
  • Projects

Repository

Set line numbers of comments tickets

Parent commits : ee9da4b48730a8b440cb7683646e046eab4e6ec5,
Children commits : eded60cbc058da4bf4f020c3485922f316f62305,

By Laurent Defert on 2014-10-25 11:59:27
Set line numbers of comments tickets

Browse content
Difference with parent commit ee9da4b48730a8b440cb7683646e046eab4e6ec5
Files modified:
kissspm/tabs/tracker/comments_ticket.py
--- 
+++ 
@@ -113,13 +113,18 @@
                 comment += value
                 if line_no > last_ticket_line:
                     rendered = highlight(comment, lexer, HtmlFormatter())
-                    ticket.set_code_content(commit.id, rendered, path, content_sha)
+                    ticket.set_code_content(commit.id, rendered, path, content_sha, last_ticket_line - self.TRAILING_LINES)
                     comment = None
 
             if self._is_comment(token):
                 for category, regexp in self.regexp.iteritems():
                     if regexp.search(value):
                         ticket_id = self._get_ticket_id(value)
+
+                        # Ignore any comment that is duplicated
+                        if ticket_id in tickets:
+                            continue
+
                         last_ticket_line = line_no + self.TRAILING_LINES
                         comment = last_line
                         if ticket_id not in self.tracker.tickets[category]:
@@ -132,7 +137,8 @@
                             ticket = self.tracker.tickets[category][ticket_id]
                         tickets.add(ticket)
 
-        if comment:
-            ticket.set_code_content(commit.id, comment, path, content_sha)
+        if comment is not None:
+            rendered = highlight(comment, lexer, HtmlFormatter())
+            ticket.set_code_content(commit.id, rendered, path, content_sha, last_ticket_line - self.TRAILING_LINES)
 
         return tickets

kissspm/tabs/tracker/ticket.py
--- 
+++ 
@@ -46,7 +46,7 @@
 
     def load(self):
         TemplatePage.load(self)
-        self.changed  = False
+        self.changed = False
 
     def parse_file(self, commit_id, file_sha, content):
         # Parse the ticket
@@ -97,14 +97,18 @@
         self.set_meta(commit_id, 'Initial commit url', self.repo_tab.get_relative_url(self, 'commits/%s/%s.html' % (commit_id[:2], commit_id[2:])))
         self.set_meta(commit_id, 'Created by', commit['author'])
 
-    def set_code_content(self, commit_id, content, path, content_sha):
+    def set_code_content(self, commit_id, content, path, content_sha, line):
         if self.meta.get('Content', '') == content:
             return
 
         commit = self.repo.get_commit(commit_id)
         self.set_meta(commit_id, 'Content', content)
         self.set_meta(commit_id, 'File', path)
-        self.set_meta(commit_id, 'File url', self.repo_tab.get_relative_url(self, 'files/%s/%s.html' % (content_sha[:2], content_sha[2:])))
+
+        url = 'files/%s/%s.html' % (content_sha[:2], content_sha[2:])
+        url = self.repo_tab.get_relative_url(self, url)
+        url += '#%i' % (line - 1)
+        self.set_meta(commit_id, 'File url', url)
         self.set_meta(commit_id, 'Last changed', commit['date'], history=False)
         self.set_meta(commit_id, 'Last changed by', commit['author'], history=False)
         self.ticket_creation = False

Generated with KisssPM