diff --git a/lib/ack.js b/lib/ack.js index b3e90d4..3112c9a 100644 --- a/lib/ack.js +++ b/lib/ack.js @@ -6,7 +6,7 @@ var fs = require('./fs') , join = require('path').join -var KEYWORDS = ['TODO', 'BUG', 'FIXME', 'OPTIMIZE'].join('|') +var KEYWORDS = ['TODO', 'BUG', 'FIXME', 'OPTIMIZE', 'REVIEW'].join('|') , running = 0 , concurrency = 198 @@ -62,40 +62,51 @@ var ack = module.exports = function ack (path, list, cb) { linum++ if (!pattern.test(line)) continue - // Assignee is the first occurence of @\w + // Old-style comments + var matches = line.match(new RegExp('('+KEYWORDS+'):(\\d{4,}-\\d{2}-\\d{2}):([^:]+):(.*)', 'g')) + if (matches != null) { + matches = matches.toString().split(':') + var labels = ['#'+matches[0].toLowerCase(), '#due['+matches[1]+']'] + , assignee = '@'+matches[2] + , title = matches[3] + , body = ''; + } - var assignee = (line.match(/@[\w\[\d\]-_]*/g)||['@none'])[0] + else { + // Assignee is the first occurence of @\w - // Title is the first line of the comment - // Assignee, keyword and commentspesific characters are removed. + var assignee = (line.match(/@[\w\[\d\]-_]*/g)||['@none'])[0] - var title = line.replace(new RegExp('.*('+KEYWORDS+')'), '') - .replace(assignee, '') - .replace(/[^a-z0-9\!\]\)]*$/i, '').trim() + // Title is the first line of the comment + // Assignee, keyword and commentspesific characters are removed. - // Body is every line after the title - // Commentspesific characters are removed + var title = line.replace(new RegExp('.*('+KEYWORDS+')'), '') + .replace(assignee, '') + .replace(/[^a-z0-9\!\]\)]*$/i, '').trim() - var body = (function body() { - var next = lines.shift() - if (/[\\s]*[\\\*\%\-(" )"]{0,3}[\|]/g.test(next)) { - linum++ - return next.split('|').slice(1).join('').trim()+'\n'+body() - } else { - lines.unshift(next) - return '' - } - })() + // Body is every line after the title + // Commentspesific characters are removed - // Labels are every word that starts with a hash "#" + var body = (function body() { + var next = lines.shift() + if (/[\\s]*[\\\*\%\-(" )"]{0,3}[\|]/g.test(next)) { + linum++ + return next.split('|').slice(1).join('').trim()+'\n'+body() + } else { + lines.unshift(next) + return '' + } + })() - var labels = ((title+body).match(/#[\w]*[\[\]0-9\.]*/gi) || []) - labels.unshift('#'+line.match(pattern)[0]) - labels.filter(function (label) { return label.length > 1 }) - labels = labels.map(function (label) { - return label.toLowerCase() - }) + // Labels are every word that starts with a hash "#" + var labels = ((title+body).match(/#[\w]*[\[\]0-9\.]*/gi) || []) + labels.unshift('#'+line.match(pattern)[0]) + labels.filter(function (label) { return label.length > 1 }) + labels = labels.map(function (label) { + return label.toLowerCase() + }) + } var done = labels[0] == '#done' ? true : false // Final task-object diff --git a/lib/pool.js b/lib/pool.js index 85fc1ee..0859a5b 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -93,7 +93,11 @@ exports.find = function taskpoolFind (qargs, cb) { matches.push(true) } } - else if (tlabel == qlabel.key) matches.push(true) + else { + var valexists = tlabel.indexOf('[') + tlabel = valexists != -1 ? tlabel.substr(0, valexists) : tlabel + if (tlabel == qlabel.key) matches.push(true) + } }) }) } @@ -141,9 +145,7 @@ exports.update = function taskpoolUpdate (paths, cb) { taskpool.ack(path, project.ignore, function (err, tasks) { if (err) return cb(err) tasks.forEach(function (task, i) { - var exists = taskpool.db.find('__uuid__', task['__uuid__']) - if (exists) updates.modified.push(task) - else updates.added.push(task) + updates.added.push(task) new Task(task)