Skip to content

Commit

Permalink
fix: markdown endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardojdsilva87 committed Oct 28, 2024
1 parent b153307 commit 0a41710
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions contributors.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def main():
repository_list,
sponsor_info,
link_to_profile,
ghe,
)
json_writer.write_to_json(
filename="contributors.json",
Expand Down
8 changes: 7 additions & 1 deletion markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions test_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def test_write_to_markdown(self, mock_file):
person1,
person2,
]
ghe = ""

write_to_markdown(
collaborators,
Expand All @@ -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")
Expand Down Expand Up @@ -93,6 +95,7 @@ def test_write_to_markdown_with_sponsors(self, mock_file):
person1,
person2,
]
ghe = ""

write_to_markdown(
collaborators,
Expand All @@ -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")
Expand Down Expand Up @@ -147,6 +151,7 @@ def test_write_to_markdown_without_link_to_profile(self, mock_file):
person1,
person2,
]
ghe = ""

write_to_markdown(
collaborators,
Expand All @@ -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")
Expand Down

0 comments on commit 0a41710

Please sign in to comment.