From e60dbba3e2811fd44cdfa2924d9ea364e3a01c43 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Mon, 24 May 2010 23:00:07 +0200 Subject: Properly detect and show commits in new branches. --- gitnoti.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3