mirror of
https://github.com/ditkrg/todo-to-issue-action.git
synced 2026-01-22 22:06:43 +00:00
Check commits array is not empty
This commit is contained in:
parent
4b6c80501f
commit
1169721b22
5
main.py
5
main.py
@ -67,7 +67,7 @@ class GitHubClient(object):
|
||||
|
||||
def get_last_diff(self):
|
||||
"""Get the last diff."""
|
||||
if self.before != '0000000000000000000000000000000000000000' or len(self.commits) == 0:
|
||||
if self.before != '0000000000000000000000000000000000000000':
|
||||
# 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:
|
||||
@ -275,6 +275,7 @@ class GitHubClient(object):
|
||||
else:
|
||||
print('Issue card could not be added to project')
|
||||
|
||||
|
||||
class TodoParser(object):
|
||||
"""Parser for extracting information from a given diff file."""
|
||||
FILE_HUNK_PATTERN = r'(?<=diff)(.*?)(?=diff\s--git\s)'
|
||||
@ -603,9 +604,11 @@ class TodoParser(object):
|
||||
projects = list(filter(None, projects.split(',')))
|
||||
return projects
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Create a basic client for communicating with GitHub, automatically initialised with environment variables.
|
||||
client = GitHubClient()
|
||||
if len(client.commits) != 0:
|
||||
# Get the diff from the last pushed commit.
|
||||
last_diff = StringIO(client.get_last_diff())
|
||||
# Parse the diff for TODOs and create an Issue object for each.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user