summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2009-08-29 20:47:32 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2009-08-29 20:47:32 +0200
commit13d9811a2f5868125a40586a3af1414c9fb2dc31 (patch)
treed1777f681f964463504a645a4dc931c7baa4450e
parent91b5ee80601e1a2ad7106adc31fdd86f0692b314 (diff)
Detect removal of repos.
Use optparse to get LoopingCall interval. Fixed new_paths iterator.
-rwxr-xr-xgitnoti.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/gitnoti.py b/gitnoti.py
index ece0d02..28e3ffb 100755
--- a/gitnoti.py
+++ b/gitnoti.py
@@ -11,6 +11,7 @@ parser.add_option('-s', '--host')
parser.add_option('-n', '--nick', default = 'git')
parser.add_option('-d', '--dir')
parser.add_option('-c', '--channel')
+parser.add_option('-i', '--interval', type = 'int', default = 30)
(options, args) = parser.parse_args()
@@ -44,8 +45,14 @@ def check_repos(bot):
else:
old_paths = [os.path.basename(x[0].path) for x in repos]
new_paths = [x for x in repo_paths if not x in old_paths]
- for n in new_paths:
- repos.append([git.Repo('%s/%s' % (root, x)), None])
+ del_paths = [x for x in old_paths if not x in repo_paths]
+ del_repos = [x for x in repos if os.path.basename(x[0].path) in del_paths]
+ if del_repos:
+ bot.gitmsg('Removed repo%s: %s' % ('' if len(del_paths) == 1 else '', ', '.join([os.path.splitext(x)[0] for x in del_paths])))
+ for i in del_repos:
+ repos.remove(i)
+ for i in new_paths:
+ repos.append([git.Repo('%s/%s' % (root, i)), None])
if new_paths:
bot.gitmsg('New repo%s: %s' % ('' if len(new_paths) == 1 else 's', ', '.join([os.path.splitext(x)[0] for x in new_paths])))
@@ -70,7 +77,7 @@ class Bot(irc.IRCClient):
def signedOn(self):
self.join(options.channel)
self.repeater = LoopingCall(check_repos, self)
- self.repeater.start(5)
+ self.repeater.start(options.interval)
def privmsg(self, user, channel, message):
private = channel == self.nickname