summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2010-05-28 20:07:47 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2010-05-28 20:07:47 +0200
commitdf2017b81b626dae38f9d53b81a8c0df9997bc81 (patch)
tree3abf92de843fe450a1a71ac0632d38769e266759
parente60dbba3e2811fd44cdfa2924d9ea364e3a01c43 (diff)
Detect deleted branches.
This also fixes the while-loop not hanging forever when the lock file is deleted.
-rwxr-xr-xgitnoti.py10
1 files changed, 9 insertions, 1 deletions
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]: