Skip to content

Commit

Permalink
Make SHA snarfing optional.
Browse files Browse the repository at this point in the history
To disable: config plugins.Git.shaSnarfing False
  • Loading branch information
mmueller committed Mar 3, 2013
1 parent a096d7c commit b20b5cc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -141,6 +141,10 @@ to absolute paths. The settings are found within `supybot.plugins.Git`:
This will affect output from the periodic polling as well as the log
command. Default: 5

* `shaSnarfing`: Enables or disables SHA sharfing, a feature which watches the
channel for mentions of a SHA and replies with the description of the
matching commit, if found. Default: True

How Notification Works
----------------------

Expand Down
4 changes: 4 additions & 0 deletions config.py
Expand Up @@ -49,4 +49,8 @@ def configure(advanced):
registry.NonNegativeInteger(5, """How many commits are displayed at
once from each repository."""))

conf.registerGlobalValue(Git, 'shaSnarfing',
registry.Boolean(True, """Look for SHAs in user messages written to the
channel, and reply with the commit description if one is found."""))

# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
19 changes: 10 additions & 9 deletions plugin.py
Expand Up @@ -472,15 +472,16 @@ def _schedule_next_event(self):

def _snarf(self, irc, msg, match):
r"""\b(?P<sha>[0-9a-f]{6,40})\b"""
sha = match.group('sha')
channel = msg.args[0]
repositories = filter(lambda r: channel in r.channels,
self.repository_list)
for repository in repositories:
commit = repository.get_commit(sha)
if commit:
self._display_commits(irc, channel, repository, [commit])
break
if self.registryValue('shaSnarfing'):
sha = match.group('sha')
channel = msg.args[0]
repositories = filter(lambda r: channel in r.channels,
self.repository_list)
for repository in repositories:
commit = repository.get_commit(sha)
if commit:
self._display_commits(irc, channel, repository, [commit])
break

def _stop_polling(self):
# Never allow an exception to propagate since this is called in die()
Expand Down

0 comments on commit b20b5cc

Please sign in to comment.