mirror of
https://github.com/ditkrg/todo-to-issue-action.git
synced 2026-01-22 22:06:43 +00:00
refactor: move GitHub-specific code into class
Add a new method, get_issue_url(), which returns the VCS-specific web URL for viewing an issue. This results in moving GitHub-specific code from main into GitHubClient, but with no change in behavior.
This commit is contained in:
parent
714153eaf3
commit
c05a9e3f1a
@ -351,3 +351,5 @@ class GitHubClient(object):
|
||||
return pr_update_request.status_code
|
||||
return pr_request.status_code
|
||||
|
||||
def get_issue_url(self, new_issue_number):
|
||||
return f'Issue URL: {self.line_base_url}{self.repo}/issues/{new_issue_number}'
|
||||
|
||||
2
main.py
2
main.py
@ -102,7 +102,7 @@ if __name__ == "__main__":
|
||||
# Duplicate the line to retain the comment syntax.
|
||||
new_line = file_lines[line_number]
|
||||
remove = fr'{raw_issue.identifier}.*{raw_issue.title}'
|
||||
insert = f'Issue URL: {client.line_base_url}{client.repo}/issues/{new_issue_number}'
|
||||
insert = client.get_issue_url(new_issue_number)
|
||||
new_line = re.sub(remove, insert, new_line)
|
||||
# Check if the URL line already exists, if so abort.
|
||||
if line_number == len(file_lines) - 1 or file_lines[line_number + 1] != new_line:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user