From 61dcc147f4f440a5e3434f691c925d4eb5cd31a9 Mon Sep 17 00:00:00 2001 From: Shakar Bakr <5h4k4r.b4kr@gmail.com> Date: Sun, 15 Jun 2025 13:57:00 +0300 Subject: [PATCH] Update diff_url logic in GitHubClient.py to simplify commit comparison handling. Adjusted the URL for single commit cases and removed unnecessary comparisons against an empty tree. Signed-off-by: Shakar Bakr <5h4k4r.b4kr@gmail.com> --- GitHubClient.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/GitHubClient.py b/GitHubClient.py index 0ba02a5..f1ccce4 100644 --- a/GitHubClient.py +++ b/GitHubClient.py @@ -89,15 +89,14 @@ class GitHubClient(Client): # There is a valid before SHA to compare with, or this is a release being created. diff_url = f'{self.repos_url}{self.repo}/compare/{self.before}...{self.sha}' elif len(self.commits) == 1: - # There is only one commit - compare against empty tree to get all files - diff_url = f'{self.repos_url}{self.repo}/compare/4b825dc642cb6eb9a060e54bf8d69288fbee4904...{self.sha}' + # There is only one commit. + diff_url = f'{self.repos_url}{self.repo}/commits/{self.sha}' elif len(self.commits) > 1: # There are several commits: compare with the oldest one. oldest = sorted(self.commits, key=self._get_timestamp)[0]['id'] diff_url = f'{self.repos_url}{self.repo}/compare/{oldest}...{self.sha}' else: - # No commits info available, compare against empty tree to get all files - diff_url = f'{self.repos_url}{self.repo}/compare/4b825dc642cb6eb9a060e54bf8d69288fbee4904...{self.sha}' + return None diff_headers = { 'Accept': 'application/vnd.github.v3.diff',