Mercurial > p > roundup > code
changeset 4171:028954c0f301 gsoc-2009
Rename svnauditor
| author | Pygi <pygi@users.sourceforge.net> |
|---|---|
| date | Thu, 02 Jul 2009 18:15:46 +0000 |
| parents | 5b6e7005435a |
| children | 97d81ee7a0c3 |
| files | scripts/notify-roundup/detectors/svnauditor.py scripts/notify-roundup/detectors/vcsauditor.py |
| diffstat | 2 files changed, 74 insertions(+), 74 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/notify-roundup/detectors/svnauditor.py Thu Jul 02 18:13:59 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -# Subversion integration auditor -# -# Watches for messages formatted by the notify-roundup.py Subversion hook -# script, and parses the meta-data out of them, removing it from the -# message body in the process. -# -# Place this file in your tracker's "detectors" directory. -# -# See end of file for change history - -import re, sets - -import roundup.date - -import ConfigParser - -vcs_msg = re.compile('^(revision|repos|host|date|summary)=(.*)$') -ini_path = '/path/to/notify-roundup.ini' - -def parse_message(db, cl, nodeid, newvalues): - '''Parse an incoming message for VCS (Subversion right now) information. - ''' - - # collect up our meta-data from the message - info = {} - content = [] - for line in newvalues.get('content', '').splitlines(): - m = vcs_msg.match(line) - if not m: - content.append(line) - continue - info[m.group(1)] = m.group(2).strip() - - # only continue if all five pieces of information are present - if len(info) != 5: - return - - # look up the repository id - try: - vcs_repo_id = db.vcs_repo.stringFind(path=info['repos'], - host=info['host'])[0] - except IndexError: - #logger.error('no repository %s in tracker'%repos.repos_dir) - return - - # create the subversion revision item - vcs_rev_id = db.vcs_rev.create(repository=vcs_repo_id, - revision=int(info['revision'])) - - # minor bit of content cleaning - remove the single leading blank line - if content and not content[0].strip(): - del content[0] - - # set the info on the message - newvalues['content'] = '\n'.join(content) - newvalues['date'] = roundup.date.Date(info['date']) - newvalues['summary'] = info['summary'] - newvalues['revision'] = vcs_rev_id - -def undo_title(db, cl, nodeid, newvalues): - '''Don't change the title of issues to "vcs commit message..."''' - if newvalues.get('title', '').lower().startswith('vcs commit message'): - del newvalues['title'] - - -def init(db): - db.msg.audit('create', parse_message) - cfg = ConfigParser.ConfigParser() - cfg.read(ini_path) - fetch_klass = cfg.get('main', 'item-class') - klass = db.getclass(fetch_klass) - klass.audit('set', undo_title) - -
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/notify-roundup/detectors/vcsauditor.py Thu Jul 02 18:15:46 2009 +0000 @@ -0,0 +1,74 @@ +# Subversion integration auditor +# +# Watches for messages formatted by the notify-roundup.py Subversion hook +# script, and parses the meta-data out of them, removing it from the +# message body in the process. +# +# Place this file in your tracker's "detectors" directory. +# +# See end of file for change history + +import re, sets + +import roundup.date + +import ConfigParser + +vcs_msg = re.compile('^(revision|repos|host|date|summary)=(.*)$') +ini_path = '/path/to/notify-roundup.ini' + +def parse_message(db, cl, nodeid, newvalues): + '''Parse an incoming message for VCS (Subversion right now) information. + ''' + + # collect up our meta-data from the message + info = {} + content = [] + for line in newvalues.get('content', '').splitlines(): + m = vcs_msg.match(line) + if not m: + content.append(line) + continue + info[m.group(1)] = m.group(2).strip() + + # only continue if all five pieces of information are present + if len(info) != 5: + return + + # look up the repository id + try: + vcs_repo_id = db.vcs_repo.stringFind(path=info['repos'], + host=info['host'])[0] + except IndexError: + #logger.error('no repository %s in tracker'%repos.repos_dir) + return + + # create the subversion revision item + vcs_rev_id = db.vcs_rev.create(repository=vcs_repo_id, + revision=int(info['revision'])) + + # minor bit of content cleaning - remove the single leading blank line + if content and not content[0].strip(): + del content[0] + + # set the info on the message + newvalues['content'] = '\n'.join(content) + newvalues['date'] = roundup.date.Date(info['date']) + newvalues['summary'] = info['summary'] + newvalues['revision'] = vcs_rev_id + +def undo_title(db, cl, nodeid, newvalues): + '''Don't change the title of issues to "vcs commit message..."''' + if newvalues.get('title', '').lower().startswith('vcs commit message'): + del newvalues['title'] + + +def init(db): + db.msg.audit('create', parse_message) + cfg = ConfigParser.ConfigParser() + cfg.read(ini_path) + fetch_klass = cfg.get('main', 'item-class') + klass = db.getclass(fetch_klass) + klass.audit('set', undo_title) + +
