From d746775d9354351c688d4e584c3f2b90c5f71cee Mon Sep 17 00:00:00 2001 From: jonasbreuer Date: Tue, 6 May 2025 13:32:22 +0200 Subject: [PATCH 1/2] feat: consider GH_ENTERPRISE_URL env in markdown author URL --- issue_metrics.py | 3 +++ test_markdown_writer.py | 13 ++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/issue_metrics.py b/issue_metrics.py index ff3c6ca..a1b3f11 100644 --- a/issue_metrics.py +++ b/issue_metrics.py @@ -284,6 +284,7 @@ def main(): # pragma: no cover non_mentioning_links=False, report_title=report_title, output_file=output_file, + ghe=ghe, ) return else: @@ -309,6 +310,7 @@ def main(): # pragma: no cover non_mentioning_links=False, report_title=report_title, output_file=output_file, + ghe=ghe, ) return @@ -371,6 +373,7 @@ def main(): # pragma: no cover non_mentioning_links=non_mentioning_links, report_title=report_title, output_file=output_file, + ghe=ghe, ) evaluate_markdown_file_size(output_file) diff --git a/test_markdown_writer.py b/test_markdown_writer.py index 1d63db5..a9259e6 100644 --- a/test_markdown_writer.py +++ b/test_markdown_writer.py @@ -298,10 +298,11 @@ def test_write_to_markdown_no_issues(self): "HIDE_TIME_TO_ANSWER": "True", "HIDE_LABEL_METRICS": "True", "NON_MENTIONING_LINKS": "True", + "GH_ENTERPRISE_URL": "https://github.mycompany.com", }, ) class TestWriteToMarkdownWithEnv(unittest.TestCase): - """Test the write_to_markdown function with the HIDE* and NON_MENTIONING_LINKS environment variables set.""" + """Test the write_to_markdown function with the HIDE*, NON_MENTIONING_LINKS and GH_ENTERPRISE_URL environment variables set.""" def test_writes_markdown_file_with_non_hidden_columns_only(self): """ @@ -313,7 +314,7 @@ def test_writes_markdown_file_with_non_hidden_columns_only(self): issues_with_metrics = [ IssueWithMetrics( title="Issue 1", - html_url="https://github.com/user/repo/issues/1", + html_url="https://github.mycompany.com/user/repo/issues/1", author="alice", created_at=timedelta(days=-5), time_to_first_response=timedelta(minutes=10), @@ -326,7 +327,7 @@ def test_writes_markdown_file_with_non_hidden_columns_only(self): ), IssueWithMetrics( title="Issue 2", - html_url="https://github.com/user/repo/issues/2", + html_url="https://github.mycompany.com/user/repo/issues/2", author="bob", created_at=timedelta(days=-5), time_to_first_response=timedelta(minutes=20), @@ -347,6 +348,7 @@ def test_writes_markdown_file_with_non_hidden_columns_only(self): num_issues_opened = 2 num_issues_closed = 2 num_mentor_count = 5 + ghe = "https://github.mycompany.com" # Call the function write_to_markdown( @@ -366,6 +368,7 @@ def test_writes_markdown_file_with_non_hidden_columns_only(self): non_mentioning_links=True, report_title="Issue Metrics", output_file="issue_metrics.md", + ghe=ghe, ) # Check that the function writes the correct markdown file @@ -381,8 +384,8 @@ def test_writes_markdown_file_with_non_hidden_columns_only(self): "| Total number of items created | 2 |\n\n" "| Title | URL | Author | Created At |\n" "| --- | --- | --- | --- |\n" - "| Issue 1 | https://www.github.com/user/repo/issues/1 | [alice](https://github.com/alice) | -5 days, 0:00:00 |\n" - "| Issue 2 | https://www.github.com/user/repo/issues/2 | [bob](https://github.com/bob) | -5 days, 0:00:00 |\n\n" + "| Issue 1 | https://www.github.mycompany.com/user/repo/issues/1 | [alice](https://github.mycompany.com/alice) | -5 days, 0:00:00 |\n" + "| Issue 2 | https://www.github.mycompany.com/user/repo/issues/2 | [bob](https://github.mycompany.com/bob) | -5 days, 0:00:00 |\n\n" "_This report was generated with the [Issue Metrics Action](https://github.com/github/issue-metrics)_\n" "Search query used to find these items: `repo:user/repo is:issue`\n" ) From 5477ea473302ac6da177eb47364cfd810fa747b6 Mon Sep 17 00:00:00 2001 From: jonasbreuer Date: Tue, 6 May 2025 14:27:31 +0200 Subject: [PATCH 2/2] style: fix linting issues in ghe-author-link feature --- test_markdown_writer.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/test_markdown_writer.py b/test_markdown_writer.py index a9259e6..3927106 100644 --- a/test_markdown_writer.py +++ b/test_markdown_writer.py @@ -298,11 +298,15 @@ def test_write_to_markdown_no_issues(self): "HIDE_TIME_TO_ANSWER": "True", "HIDE_LABEL_METRICS": "True", "NON_MENTIONING_LINKS": "True", - "GH_ENTERPRISE_URL": "https://github.mycompany.com", + "GH_ENTERPRISE_URL": "https://ghe.com", }, ) class TestWriteToMarkdownWithEnv(unittest.TestCase): - """Test the write_to_markdown function with the HIDE*, NON_MENTIONING_LINKS and GH_ENTERPRISE_URL environment variables set.""" + """Test the write_to_markdown function with the following environment variables set: + - HIDE*, + - NON_MENTIONING_LINKS + - GH_ENTERPRISE_URL + """ def test_writes_markdown_file_with_non_hidden_columns_only(self): """ @@ -314,7 +318,7 @@ def test_writes_markdown_file_with_non_hidden_columns_only(self): issues_with_metrics = [ IssueWithMetrics( title="Issue 1", - html_url="https://github.mycompany.com/user/repo/issues/1", + html_url="https://ghe.com/user/repo/issues/1", author="alice", created_at=timedelta(days=-5), time_to_first_response=timedelta(minutes=10), @@ -327,7 +331,7 @@ def test_writes_markdown_file_with_non_hidden_columns_only(self): ), IssueWithMetrics( title="Issue 2", - html_url="https://github.mycompany.com/user/repo/issues/2", + html_url="https://ghe.com/user/repo/issues/2", author="bob", created_at=timedelta(days=-5), time_to_first_response=timedelta(minutes=20), @@ -348,7 +352,7 @@ def test_writes_markdown_file_with_non_hidden_columns_only(self): num_issues_opened = 2 num_issues_closed = 2 num_mentor_count = 5 - ghe = "https://github.mycompany.com" + ghe = "https://ghe.com" # Call the function write_to_markdown( @@ -384,8 +388,8 @@ def test_writes_markdown_file_with_non_hidden_columns_only(self): "| Total number of items created | 2 |\n\n" "| Title | URL | Author | Created At |\n" "| --- | --- | --- | --- |\n" - "| Issue 1 | https://www.github.mycompany.com/user/repo/issues/1 | [alice](https://github.mycompany.com/alice) | -5 days, 0:00:00 |\n" - "| Issue 2 | https://www.github.mycompany.com/user/repo/issues/2 | [bob](https://github.mycompany.com/bob) | -5 days, 0:00:00 |\n\n" + "| Issue 1 | https://www.ghe.com/user/repo/issues/1 | [alice](https://ghe.com/alice) | -5 days, 0:00:00 |\n" + "| Issue 2 | https://www.ghe.com/user/repo/issues/2 | [bob](https://ghe.com/bob) | -5 days, 0:00:00 |\n\n" "_This report was generated with the [Issue Metrics Action](https://github.com/github/issue-metrics)_\n" "Search query used to find these items: `repo:user/repo is:issue`\n" )