Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: header seperator count #177

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions stale_repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,12 @@ def write_to_markdown(
markdown_file.write(" Days Since Last Release |")
if "pr" in additional_metrics:
markdown_file.write(" Days Since Last PR |")
markdown_file.write("\n| --- | --- | --- | ---: |")
if additional_metrics and (
"release" in additional_metrics or "pr" in additional_metrics
):
markdown_file.write(" ---: |")
markdown_file.write("\n| --- | --- | --- | --- |")
if additional_metrics:
if "release" in additional_metrics:
markdown_file.write(" --- |")
if "pr" in additional_metrics:
markdown_file.write(" --- |")
markdown_file.write("\n")
for repo_data in inactive_repos:
markdown_file.write(
Expand Down
21 changes: 19 additions & 2 deletions test_stale_repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,12 +576,16 @@ def test_write_to_markdown(self):
"days_inactive": 30,
"last_push_date": thirty_days_ago.date().isoformat(),
"visibility": "private",
"days_since_last_release": None,
"days_since_last_pr": None,
},
{
"url": "https://github.com/example/repo2",
"days_inactive": 40,
"last_push_date": forty_days_ago.date().isoformat(),
"visibility": "public",
"days_since_last_release": None,
"days_since_last_pr": None,
},
]

Expand All @@ -591,7 +595,12 @@ def test_write_to_markdown(self):
mock_file = MagicMock()

# Call the write_to_markdown function with the mock file object
write_to_markdown(inactive_repos, inactive_days_threshold, file=mock_file)
write_to_markdown(
inactive_repos,
inactive_days_threshold,
additional_metrics=["release", "pr"],
file=mock_file,
)

# Check that the mock file object was called with the expected data
expected_calls = [
Expand All @@ -602,17 +611,25 @@ def test_write_to_markdown(self):
call.write(
"| Repository URL | Days Inactive | Last Push Date | Visibility |"
),
call.write("\n| --- | --- | --- | ---: |"),
call.write(" Days Since Last Release |"),
call.write(" Days Since Last PR |"),
call.write("\n| --- | --- | --- | --- |"),
call.write(" --- |"),
call.write(" --- |"),
call.write("\n"),
call.write(
f"| https://github.com/example/repo2 | 40 |\
{forty_days_ago.date().isoformat()} | public |"
),
call.write(" None |"),
call.write(" None |"),
call.write("\n"),
call.write(
f"| https://github.com/example/repo1 | 30 |\
{thirty_days_ago.date().isoformat()} | private |"
),
call.write(" None |"),
call.write(" None |"),
call.write("\n"),
]
mock_file.__enter__.return_value.assert_has_calls(expected_calls)
Expand Down