MDK Tracker commenting
authorAndrew Nicols <andrew@nicols.co.uk>
Fri, 26 Dec 2014 07:05:26 +0000 (15:05 +0800)
committerFrederic Massart <fmcell@gmail.com>
Fri, 6 Mar 2015 14:45:36 +0000 (15:45 +0100)
extra/bash_completion
mdk/commands/tracker.py
mdk/jira.py

index d4e96df..0a2220c 100644 (file)
@@ -219,7 +219,7 @@ function _mdk() {
                 fi
                 ;;
             tracker)
-                OPTS="--testing --add-labels --remove-labels"
+                OPTS="--testing --add-labels --remove-labels --comment"
                 ;;
             update)
                 OPTS="--integration --stable --all --upgrade --update-cache"
index 6ed449a..3ba7f1b 100644 (file)
@@ -27,7 +27,7 @@ import textwrap
 import re
 from ..command import Command
 from ..jira import Jira
-from ..tools import parseBranch
+from ..tools import parseBranch, getText
 
 
 class TrackerCommand(Command):
@@ -66,6 +66,13 @@ class TrackerCommand(Command):
                 'metavar':  'labels',
                 'nargs': '+',
             }
+        ),
+        (
+            ['--comment'],
+            {
+                'action': 'store_true',
+                'help': 'add a comment to the issue',
+            }
         )
     ]
     _description = 'Interact with Moodle tracker'
@@ -105,6 +112,10 @@ class TrackerCommand(Command):
                 self.argumentError('The label \'triaging_in_progress\' cannot be removed using MDK')
             self.Jira.removeLabels(self.mdl, args.removelabels)
 
+        if args.comment:
+            comment = getText()
+            self.Jira.addComment(self.mdl, comment)
+
         self.info(args)
 
     def info(self, args):
index 1108453..a119b17 100644 (file)
@@ -68,6 +68,19 @@ class Jira(object):
         self._load()
 
 
+    def addComment(self, key, comment):
+        """Add a comment to an issue"""
+
+        assert isinstance(comment, str), "Expected a string"
+
+        data = [
+            {'add': {'body': comment}}
+        ]
+
+        self.updateIssue(key, {'update': {'comment': data}})
+
+        return True
+
     def addLabels(self, key, labels):
         """Add labels to an issue"""