Add diff url for first branch commit

This commit is contained in:
Luis G. Valle
2021-08-11 07:52:36 +02:00
parent 0db9bdffa1
commit 30f81ca3e0

View File

@@ -63,6 +63,10 @@ class GitHubClient(object):
def get_last_diff(self): def get_last_diff(self):
"""Get the last diff based on the SHA of the last two commits.""" """Get the last diff based on the SHA of the last two commits."""
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_url = f'{self.repos_url}{self.repo}/compare/{self.before}...{self.sha}'
diff_headers = { diff_headers = {
'Accept': 'application/vnd.github.v3.diff', 'Accept': 'application/vnd.github.v3.diff',