Merge branch 'master' of github.com:FMCorz/mdk
authorFrederic Massart <fred@moodle.com>
Thu, 9 Apr 2015 02:28:36 +0000 (10:28 +0800)
committerFrederic Massart <fred@moodle.com>
Thu, 9 Apr 2015 02:28:36 +0000 (10:28 +0800)
CHANGELOG.rst
extra/bash_completion
mdk/commands/config.py
mdk/commands/css.py
mdk/commands/tracker.py
mdk/jira.py
mdk/scripts/dev.php
mdk/scripts/undev.php
mdk/tools.py
mdk/version.py
requirements.txt

index 3234fdc..c5d50ad 100644 (file)
@@ -1,6 +1,15 @@
 Changelog
 =========
 
+v1.5
+----
+
+- New ``precheck`` command
+- ``phpunit`` can run a whole test suite - Andrew Nicols
+- ``tracker`` can add comments to an issue - Andrew Nicols
+- ``tracker`` can add/remove labels to an issue - Andrew Nicols
+- ``config flatlist`` has an optional ``--grep`` argument
+
 v1.4
 ----
 
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 b0949a9..48b7bc4 100644 (file)
@@ -23,6 +23,7 @@ http://github.com/FMCorz/mdk
 """
 
 import logging
+import re
 from ..command import Command
 from ..tools import launchEditor, yesOrNo
 from ..config import ConfigObject, ConfigFileCouldNotBeLoaded
@@ -47,7 +48,15 @@ class ConfigCommand(Command):
                         {
                             'help': 'flat list of the settings'
                         },
-                        []
+                        [
+                            (
+                                ['-g', '--grep'],
+                                {
+                                    'metavar': 'string',
+                                    'help': 'filter results using regular expressions'
+                                }
+                            ),
+                        ]
                     ),
                     'list': (
                         {
@@ -107,13 +116,15 @@ class ConfigCommand(Command):
                 print u' ' * ident + '[%s]' % name
                 self.dictDisplay(setting, ident + 2)
 
-    def flatDisplay(self, data, parent=''):
+    def flatDisplay(self, data, parent='', regex=None):
         for name in sorted(data.keys()):
             setting = data[name]
             if type(setting) != dict:
+                if regex and not regex.search(parent + name):
+                    continue
                 print u'%s: %s' % (parent + name, setting)
             else:
-                self.flatDisplay(setting, parent + name + u'.')
+                self.flatDisplay(setting, parent=parent + name + u'.', regex=regex)
 
     def run(self, args):
         if args.action == 'list':
@@ -146,7 +157,10 @@ class ConfigCommand(Command):
                         current.write(new.read())
 
         elif args.action == 'flatlist':
-            self.flatDisplay(self.C.get())
+            regex = None
+            if args.grep:
+                regex = re.compile(args.grep, re.I)
+            self.flatDisplay(self.C.get(), regex=regex)
 
         elif args.action == 'show':
             setting = self.C.get(args.setting)
index d46e82e..8ad4627 100644 (file)
@@ -167,6 +167,9 @@ class LessWatcher(watchdog.events.FileSystemEventHandler):
     def on_modified(self, event):
         self.process(event)
 
+    def on_moved(self, event):
+        self.process(event)
+
     def process(self, event):
         if event.is_directory:
             return
index 9fc9ec6..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'
@@ -101,10 +108,14 @@ class TrackerCommand(Command):
         if args.removelabels:
             if 'triaged' in args.removelabels:
                 self.argumentError('The label \'triaged\' cannot be removed using MDK')
-            elif 'triaging_in_progress' in args.addlabels:
+            elif 'triaging_in_progress' in args.removelabels:
                 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"""
 
index 993152e..a658126 100644 (file)
@@ -28,6 +28,9 @@ mdk_set_config('debugdisplay', 1);
 // Any kind of password is allowed.
 mdk_set_config('passwordpolicy', 0);
 
+// Allow web cron.
+mdk_set_config('cronclionly', 0);
+
 // Debug the performance.
 mdk_set_config('perfdebug', 15);
 
index 8d78d59..a27eebe 100644 (file)
@@ -57,6 +57,10 @@ $settings = $settingspage->settings;
 $default = $settings->passwordpolicy->get_defaultsetting();
 mdk_set_config('passwordpolicy', $default);
 
+// Allow web cron.
+$default = $settings->cronclionly->get_defaultsetting();
+mdk_set_config('cronclionly', $default);
+
 
 // Theme settings.
 $settingspage = $adminroot->locate('themesettings', true);
index e277113..21d01f6 100644 (file)
@@ -117,6 +117,30 @@ def launchEditor(filepath=None, suffix='.tmp'):
     return tmpfile.name
 
 
+def getText(suffix='.md', initialText=None):
+    """Gets text from the user using an Editor
+
+    This is a shortcut to using launchEditor as it returns text rather
+    than the file in which the text entered is stored.
+
+    When the returned value is empty, the user is asked is they want to resume.
+    """
+    with tempfile.NamedTemporaryFile(suffix=suffix, delete=False) as tmpfile:
+        if initialText:
+            tmpfile.write(initialText)
+            tmpfile.flush()
+        while True:
+            editorFile = launchEditor(suffix=suffix, filepath=tmpfile.name)
+            text = None
+            with open(editorFile, 'r') as f:
+                text = f.read()
+
+            if len(text) <= 0:
+                if not yesOrNo('No content detected. Would you like to resume editing?'):
+                    return ''
+            else:
+                return text
+
 def md5file(filepath):
     """Return the md5 sum of a file
     This is terribly memory inefficient!"""
index 10ca6c8..a005f1b 100644 (file)
@@ -22,4 +22,4 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 http://github.com/FMCorz/mdk
 """
 
-__version__ = "1.4.1"
+__version__ = "1.5.0"
index 605bed3..122f58b 100644 (file)
@@ -1,6 +1,6 @@
 keyring>=3.5
-jenkinsapi>=0.2.25
+jenkinsapi==0.2.25
 MySQL-python>=1.2.3
 psycopg2>=2.4.5
 requests>=2.2.1
-watchdog>=0.8.0
\ No newline at end of file
+watchdog>=0.8.0