Skip to content

Commit

Permalink
Merge pull request #177 from github/header-fix
Browse files Browse the repository at this point in the history
fix: header seperator count
  • Loading branch information
zkoppert committed Jul 8, 2024
2 parents e8fd82d + 1ec6d4e commit d9dc177
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
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

0 comments on commit d9dc177

Please sign in to comment.