Browse Source

Add inline comments to change overview

The gerrit ui shows the inline comments on the change overview without
having to open the diff screen. This is useful for following
discussions on changes so add this to gertty as well.

Change-Id: I976ec5584e978ce4aee7075bc45394193c104889
Tobias Henkel 2 months ago
parent
commit
56d63841f5
No account linked to committer's email address
2 changed files with 24 additions and 0 deletions
  1. 1
    0
      gertty/palette.py
  2. 23
    0
      gertty/view/change.py

+ 1
- 0
gertty/palette.py View File

@@ -18,6 +18,7 @@ DEFAULT_PALETTE={
18 18
     'error': ['light red', 'dark blue'],
19 19
     'table-header': ['white,bold', ''],
20 20
     'filename': ['light cyan', ''],
21
+    'filename-inline-comment': ['dark cyan', ''],
21 22
     'focused-filename': ['light cyan,standout', ''],
22 23
     'positive-label': ['dark green', ''],
23 24
     'negative-label': ['dark red', ''],

+ 23
- 0
gertty/view/change.py View File

@@ -446,6 +446,29 @@ class ChangeMessageBox(mywid.HyperText):
446 446
         comment_text = ['\n'.join(lines)]
447 447
         for commentlink in self.app.config.commentlinks:
448 448
             comment_text = commentlink.run(self.app, comment_text)
449
+
450
+        inline_comments = {}
451
+        for file in message.revision.files:
452
+            comments = [c for c in file.comments
453
+                        if c.author.id == message.author.id
454
+                        and c.created == message.created]
455
+            for comment in comments:
456
+                path = comment.file.path
457
+                inline_comments.setdefault(path, [])
458
+                inline_comments[path].append((comment.line, comment.message))
459
+        for v in inline_comments.values():
460
+            v.sort()
461
+
462
+        if inline_comments:
463
+            comment_text.append(u'\n')
464
+        for key, value in inline_comments.items():
465
+            comment_text.append(('filename-inline-comment', u'%s' % key))
466
+            for line, comment in value:
467
+                if line is None:
468
+                    comment_text.append(u'\n  %s' % comment)
469
+                else:
470
+                    comment_text.append(u'\n  %s: %s\n' % (line, comment))
471
+
449 472
         self.set_text(text+comment_text)
450 473
 
451 474
 class CommitMessageBox(mywid.HyperText):

Loading…
Cancel
Save