summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2010-05-24 23:00:07 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2010-05-24 23:00:07 +0200
commite60dbba3e2811fd44cdfa2924d9ea364e3a01c43 (patch)
tree3e7baec771d79293ba1611d0d92e0b984f6f9fa4
parent5d90daea17b1d95ef654148fe7fbe4c555444b4b (diff)
Properly detect and show commits in new branches.
-rwxr-xr-xgitnoti.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/gitnoti.py b/gitnoti.py
index 191a453..a3fee3b 100755
--- a/gitnoti.py
+++ b/gitnoti.py
@@ -106,6 +106,14 @@ class ReposNotifyEvent(pyinotify.ProcessEvent):
pathname = os.path.dirname(pathname)
if len(pathname) == 1 or not pathname in repos:
return
+
+ # Check for lock file
+ if event.pathname.endswith('.lock'):
+ newname = event.pathname[:-5]
+ # Wait max 10 seconds until file is moved
+ while not os.access(newname, os.F_OK):
+ time.sleep(1)
+
l = repos[pathname]
if not l[0]:
l[0] = git.Repo(pathname)
@@ -117,9 +125,16 @@ class ReposNotifyEvent(pyinotify.ProcessEvent):
for h in repo.heads:
last = l[1][h.name] if h.name in l[1] else None
if h.commit.sha != last:
- commits = list(repo.iter_commits('%s..%s' % (last, h.name)))
+ if last: # Check against last commit
+ commits = list(repo.iter_commits('%s..%s' % (last, h.name)))
+ elif len(h.commit.parents): # Check against parent commit
+ commits = list(repo.iter_commits('%s..%s' % (h.commit.parents[0], h.name)))
+ else: # No valid commits to check against
+ continue
+
if not len(commits): # No commits
continue
+
msg = repo_commit_msg(repo, h.name, commits)
self.bot.gitmsg(msg)
l[1][h.name] = h.commit.sha