diff --git a/modules/git_webhooks/github.py b/modules/git_webhooks/github.py index 777e8ca8..7e3db56b 100644 --- a/modules/git_webhooks/github.py +++ b/modules/git_webhooks/github.py @@ -184,13 +184,17 @@ class GitHub(object): branch = utils.irc.color(branch, colors.COLOR_BRANCH) author = utils.irc.bold(data["pusher"]["name"]) - first_id = data["before"] - last_id = data["commits"][-1]["id"] - range_url = self._short_url( - COMMIT_RANGE_URL % (full_name, first_id, last_id)) + range_url = None + if len(data["commits"]): + first_id = data["before"] + last_id = data["commits"][-1]["id"] + range_url = self._short_url( + COMMIT_RANGE_URL % (full_name, first_id, last_id)) + + single_url = COMMIT_URL % (full_name, "%s"), return self._format_push(branch, author, data["commits"], - data["forced"], COMMIT_URL % (full_name, "%s"), range_url) + data["forced"], single_url, range_url) def _format_push(self, branch, author, commits, forced, single_url, range_url):