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:
Robert Alonso 2024-10-24 22:36:26 +00:00
parent 714153eaf3
commit c05a9e3f1a
2 changed files with 3 additions and 1 deletions

View File

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

View File

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