From 1ec6d4ef917553c8796391f744975e30cb251ad9 Mon Sep 17 00:00:00 2001 From: Zack Koppert Date: Mon, 8 Jul 2024 15:59:14 -0700 Subject: [PATCH] fix: header seperator count Signed-off-by: Zack Koppert --- stale_repos.py | 11 ++++++----- test_stale_repos.py | 21 +++++++++++++++++++-- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/stale_repos.py b/stale_repos.py index 3e86db4..73154fc 100755 --- a/stale_repos.py +++ b/stale_repos.py @@ -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( diff --git a/test_stale_repos.py b/test_stale_repos.py index ec8e305..376302d 100644 --- a/test_stale_repos.py +++ b/test_stale_repos.py @@ -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, }, ] @@ -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 = [ @@ -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)