diff options
-rwxr-xr-x | gitnoti.py | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -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 |