From c159a716fd5c710ecb982b42f1cdd1c198eac640 Mon Sep 17 00:00:00 2001 From: "Luis G. Valle" <354372+lgvalle@users.noreply.github.com> Date: Tue, 17 Aug 2021 08:10:04 +0200 Subject: [PATCH] Replace /compare with /commits to fetch the last diff --- action.yml | 4 ---- main.py | 9 ++------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/action.yml b/action.yml index ce41451..9fe2eee 100644 --- a/action.yml +++ b/action.yml @@ -12,10 +12,6 @@ inputs: description: "The path to the repository where the action will be used, e.g. 'alstr/my-repo' (automatically set)" required: true default: "${{ github.repository }}" - BEFORE: - description: "The SHA of the last pushed commit (automatically set)" - required: true - default: "${{ github.event.before }}" SHA: description: "The SHA of the latest commit (automatically set)" required: true diff --git a/main.py b/main.py index e18e7cf..c13e8f9 100644 --- a/main.py +++ b/main.py @@ -48,7 +48,6 @@ class GitHubClient(object): def __init__(self): self.repo = os.getenv('INPUT_REPO') - self.before = os.getenv('INPUT_BEFORE') self.sha = os.getenv('INPUT_SHA') self.token = os.getenv('INPUT_TOKEN') self.issues_url = f'{self.repos_url}{self.repo}/issues' @@ -62,12 +61,8 @@ class GitHubClient(object): self._get_existing_issues() def get_last_diff(self): - """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}' + """Get the last commit diff.""" + diff_url = f'{self.repos_url}{self.repo}/commits/{self.sha}' diff_headers = { 'Accept': 'application/vnd.github.v3.diff', 'Authorization': f'token {self.token}'