diff --git a/contributors.py b/contributors.py index 220e5c1..102b854 100644 --- a/contributors.py +++ b/contributors.py @@ -82,6 +82,7 @@ def main(): repository_list, sponsor_info, link_to_profile, + ghe, ) json_writer.write_to_json( filename="contributors.json", diff --git a/markdown.py b/markdown.py index 54ad927..a32328a 100644 --- a/markdown.py +++ b/markdown.py @@ -11,6 +11,7 @@ def write_to_markdown( repository, sponsor_info, link_to_profile, + ghe, ): """ This function writes a list of collaborators to a markdown file in table format. @@ -40,6 +41,7 @@ def write_to_markdown( repository, sponsor_info, link_to_profile, + ghe, ) # Put together the summary table including # of new contributions, # of new contributors, % new contributors, % returning contributors @@ -134,6 +136,7 @@ def get_contributor_table( repository, sponsor_info, link_to_profile, + ghe, ): """ This function returns a string containing a markdown table of the contributors and the total contribution count. @@ -182,7 +185,10 @@ def get_contributor_table( for url in commit_url_list: url = url.strip() # get the organization and repository name from the url ie. org1/repo2 from https://github.com/org1/repo2/commits?author-zkoppert - org_repo_link_name = url.split("/commits")[0].split("github.com/")[1] + api_endpoint = ghe.removeprefix("https://") if ghe else "github.com" + org_repo_link_name = url.split("/commits")[0].split(f"{api_endpoint}/")[ + 1 + ] url = f"[{org_repo_link_name}]({url})" commit_urls += f"{url}, " new_contributor = collaborator.new_contributor diff --git a/test_markdown.py b/test_markdown.py index f4e46cb..e70ab78 100644 --- a/test_markdown.py +++ b/test_markdown.py @@ -39,6 +39,7 @@ def test_write_to_markdown(self, mock_file): person1, person2, ] + ghe = "" write_to_markdown( collaborators, @@ -49,6 +50,7 @@ def test_write_to_markdown(self, mock_file): "org/repo", "false", "true", + ghe, ) mock_file.assert_called_once_with("filename", "w", encoding="utf-8") @@ -93,6 +95,7 @@ def test_write_to_markdown_with_sponsors(self, mock_file): person1, person2, ] + ghe = "" write_to_markdown( collaborators, @@ -103,6 +106,7 @@ def test_write_to_markdown_with_sponsors(self, mock_file): "org/repo", "true", "true", + ghe, ) mock_file.assert_called_once_with("filename", "w", encoding="utf-8") @@ -147,6 +151,7 @@ def test_write_to_markdown_without_link_to_profile(self, mock_file): person1, person2, ] + ghe = "" write_to_markdown( collaborators, @@ -157,6 +162,7 @@ def test_write_to_markdown_without_link_to_profile(self, mock_file): "org/repo", "false", "false", + ghe, ) mock_file.assert_called_once_with("filename", "w", encoding="utf-8")