From df2017b81b626dae38f9d53b81a8c0df9997bc81 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Fri, 28 May 2010 20:07:47 +0200 Subject: Detect deleted branches. This also fixes the while-loop not hanging forever when the lock file is deleted. --- gitnoti.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gitnoti.py b/gitnoti.py index a3fee3b..3e8b844 100755 --- a/gitnoti.py +++ b/gitnoti.py @@ -110,9 +110,17 @@ class ReposNotifyEvent(pyinotify.ProcessEvent): # Check for lock file if event.pathname.endswith('.lock'): newname = event.pathname[:-5] + i = 0 # Wait max 10 seconds until file is moved - while not os.access(newname, os.F_OK): + while not os.access(newname, os.F_OK) and os.access(event.pathname, os.F_OK) and i < 10: time.sleep(1) + i += 1 + + # Assume deleted if neither file exists. + if not os.access(newname, os.F_OK) and not os.access(event.pathname, os.F_OK): + self.bot.gitmsg('Branch \002%s\002 from repo \002%s\002 was deleted.' % + (os.path.basename(newname), os.path.splitext(os.path.basename(pathname))[0])) + return l = repos[pathname] if not l[0]: -- cgit v1.2.3