mirror of
https://github.com/ditkrg/todo-to-issue-action.git
synced 2026-01-22 22:06:43 +00:00
Replace /compare with /commits to fetch the last diff
This commit is contained in:
parent
12e626ea05
commit
c159a716fd
@ -12,10 +12,6 @@ inputs:
|
|||||||
description: "The path to the repository where the action will be used, e.g. 'alstr/my-repo' (automatically set)"
|
description: "The path to the repository where the action will be used, e.g. 'alstr/my-repo' (automatically set)"
|
||||||
required: true
|
required: true
|
||||||
default: "${{ github.repository }}"
|
default: "${{ github.repository }}"
|
||||||
BEFORE:
|
|
||||||
description: "The SHA of the last pushed commit (automatically set)"
|
|
||||||
required: true
|
|
||||||
default: "${{ github.event.before }}"
|
|
||||||
SHA:
|
SHA:
|
||||||
description: "The SHA of the latest commit (automatically set)"
|
description: "The SHA of the latest commit (automatically set)"
|
||||||
required: true
|
required: true
|
||||||
|
|||||||
7
main.py
7
main.py
@ -48,7 +48,6 @@ class GitHubClient(object):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.repo = os.getenv('INPUT_REPO')
|
self.repo = os.getenv('INPUT_REPO')
|
||||||
self.before = os.getenv('INPUT_BEFORE')
|
|
||||||
self.sha = os.getenv('INPUT_SHA')
|
self.sha = os.getenv('INPUT_SHA')
|
||||||
self.token = os.getenv('INPUT_TOKEN')
|
self.token = os.getenv('INPUT_TOKEN')
|
||||||
self.issues_url = f'{self.repos_url}{self.repo}/issues'
|
self.issues_url = f'{self.repos_url}{self.repo}/issues'
|
||||||
@ -62,12 +61,8 @@ class GitHubClient(object):
|
|||||||
self._get_existing_issues()
|
self._get_existing_issues()
|
||||||
|
|
||||||
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 commit diff."""
|
||||||
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}'
|
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 = {
|
diff_headers = {
|
||||||
'Accept': 'application/vnd.github.v3.diff',
|
'Accept': 'application/vnd.github.v3.diff',
|
||||||
'Authorization': f'token {self.token}'
|
'Authorization': f'token {self.token}'
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user