From 30f81ca3e0fb212601d1e58e0f5f13ed22676c94 Mon Sep 17 00:00:00 2001 From: "Luis G. Valle" <354372+lgvalle@users.noreply.github.com> Date: Wed, 11 Aug 2021 07:52:36 +0200 Subject: [PATCH] Add diff url for first branch commit --- main.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 6c36f92..0ff3566 100644 --- a/main.py +++ b/main.py @@ -63,7 +63,11 @@ class GitHubClient(object): def get_last_diff(self): """Get the last diff based on the SHA of the last two commits.""" - diff_url = f'{self.repos_url}{self.repo}/compare/{self.before}...{self.sha}' + if not self.before or self.before.startswith('000000'): + # Last commit SHA is empty which means this is the first commit of the branch + diff_url = f'{self.repos_url}{self.repo}/commits/{self.sha}' + else: + diff_url = f'{self.repos_url}{self.repo}/compare/{self.before}...{self.sha}' diff_headers = { 'Accept': 'application/vnd.github.v3.diff', 'Authorization': f'token {self.token}'