Replace /compare with /commits to fetch the last diff

This commit is contained in:
Luis G. Valle 2021-08-17 08:10:04 +02:00
parent 12e626ea05
commit c159a716fd
2 changed files with 2 additions and 11 deletions

View File

@ -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

View File

@ -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}'