From 03df74bf3ea7c6f1108446957cfa3f41fbd3bb69 Mon Sep 17 00:00:00 2001 From: Zack Koppert Date: Sat, 24 Aug 2024 15:10:40 -0700 Subject: [PATCH 1/2] Fix headers in markdown to reflect when its limited to date range Signed-off-by: Zack Koppert --- README.md | 4 ++-- markdown.py | 7 +++++-- test_markdown.py | 6 +++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 1637332..4bbf1fb 100644 --- a/README.md +++ b/README.md @@ -155,7 +155,7 @@ jobs: | ------------------ | ------------------- | ------------------ | | 1 | 143 | 0% | -| Username | Contribution Count | New Contributor | Commits | +| Username | All Time Contribution Count | New Contributor | Commits between 2021-01-01 and 2023-10-10 | | --------- | ------------------ | --------------- | ----------------------------------------------------------------------------------------------------------------------------------- | | @zkoppert | 143 | False | [super-linter/super-linter](https://github.com/super-linter/super-linter/commits?author=zkoppert&since=2021-01-01&until=2023-10-10) | ``` @@ -171,7 +171,7 @@ jobs: | ------------------ | ------------------- | ------------------ | | 1 | 1913 | 0% | -| Username | Contribution Count | New Contributor | Sponsor URL | Commits | +| Username | All Time Contribution Count | New Contributor | Sponsor URL | Commits between 2021-09-01 and 2023-09-30 | | --------- | ------------------ | --------------- | ---------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | | @zkoppert | 1913 | False | [Sponsor Link](https://github.com/sponsors/zkoppert) | [super-linter/super-linter](https://github.com/super-linter/super-linter/commits?author=zkoppert&since=2021-09-01&until=2023-09-30) | ``` diff --git a/markdown.py b/markdown.py index 23cfc56..1e13cec 100644 --- a/markdown.py +++ b/markdown.py @@ -161,12 +161,15 @@ def get_contributor_table( total_contributions (int): The total number of contributions made by all of the contributors. """ - columns = ["Username", "Contribution Count"] + columns = ["Username", "All Time Contribution Count"] if start_date and end_date: columns += ["New Contributor"] if sponsor_info == "true": columns += ["Sponsor URL"] - columns += ["Commits"] + if start_date and end_date: + columns += [f"Commits between {start_date} and {end_date}"] + else: + columns += ["All Commits"] headers = "| " + " | ".join(columns) + " |\n" headers += "| " + " | ".join(["---"] * len(columns)) + " |\n" diff --git a/test_markdown.py b/test_markdown.py index ebee539..f4e46cb 100644 --- a/test_markdown.py +++ b/test_markdown.py @@ -60,7 +60,7 @@ def test_write_to_markdown(self, mock_file): "| Total Contributors | Total Contributions | % New Contributors |\n| --- | --- | --- |\n| 2 | 300 | 50.0% |\n\n" ) mock_file().write.assert_any_call( - "| Username | Contribution Count | New Contributor | Commits |\n" + "| Username | All Time Contribution Count | New Contributor | Commits between 2023-01-01 and 2023-01-02 |\n" "| --- | --- | --- | --- |\n" "| @user1 | 100 | False | commit url |\n" "| @user2 | 200 | True | commit url2 |\n" @@ -114,7 +114,7 @@ def test_write_to_markdown_with_sponsors(self, mock_file): "| Total Contributors | Total Contributions | % New Contributors |\n| --- | --- | --- |\n| 2 | 300 | 50.0% |\n\n" ) mock_file().write.assert_any_call( - "| Username | Contribution Count | New Contributor | Sponsor URL | Commits |\n" + "| Username | All Time Contribution Count | New Contributor | Sponsor URL | Commits between 2023-01-01 and 2023-01-02 |\n" "| --- | --- | --- | --- | --- |\n" "| @user1 | 100 | False | [Sponsor Link](sponsor_url_1) | commit url |\n" "| @user2 | 200 | True | not sponsorable | commit url2 |\n" @@ -168,7 +168,7 @@ def test_write_to_markdown_without_link_to_profile(self, mock_file): "| Total Contributors | Total Contributions | % New Contributors |\n| --- | --- | --- |\n| 2 | 300 | 50.0% |\n\n" ) mock_file().write.assert_any_call( - "| Username | Contribution Count | New Contributor | Commits |\n" + "| Username | All Time Contribution Count | New Contributor | Commits between 2023-01-01 and 2023-01-02 |\n" "| --- | --- | --- | --- |\n" "| user1 | 100 | False | commit url |\n" "| user2 | 200 | True | commit url2 |\n" From 73e7b14782d23fe114fd82510e7edcef262b8af2 Mon Sep 17 00:00:00 2001 From: Zack Koppert Date: Sat, 24 Aug 2024 15:20:31 -0700 Subject: [PATCH 2/2] chore: run prettier on markdown Signed-off-by: Zack Koppert --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 4bbf1fb..efab3d9 100644 --- a/README.md +++ b/README.md @@ -155,9 +155,9 @@ jobs: | ------------------ | ------------------- | ------------------ | | 1 | 143 | 0% | -| Username | All Time Contribution Count | New Contributor | Commits between 2021-01-01 and 2023-10-10 | -| --------- | ------------------ | --------------- | ----------------------------------------------------------------------------------------------------------------------------------- | -| @zkoppert | 143 | False | [super-linter/super-linter](https://github.com/super-linter/super-linter/commits?author=zkoppert&since=2021-01-01&until=2023-10-10) | +| Username | All Time Contribution Count | New Contributor | Commits between 2021-01-01 and 2023-10-10 | +| --------- | --------------------------- | --------------- | ----------------------------------------------------------------------------------------------------------------------------------- | +| @zkoppert | 143 | False | [super-linter/super-linter](https://github.com/super-linter/super-linter/commits?author=zkoppert&since=2021-01-01&until=2023-10-10) | ``` ## Example Markdown output with no dates supplied @@ -171,9 +171,9 @@ jobs: | ------------------ | ------------------- | ------------------ | | 1 | 1913 | 0% | -| Username | All Time Contribution Count | New Contributor | Sponsor URL | Commits between 2021-09-01 and 2023-09-30 | -| --------- | ------------------ | --------------- | ---------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | -| @zkoppert | 1913 | False | [Sponsor Link](https://github.com/sponsors/zkoppert) | [super-linter/super-linter](https://github.com/super-linter/super-linter/commits?author=zkoppert&since=2021-09-01&until=2023-09-30) | +| Username | All Time Contribution Count | New Contributor | Sponsor URL | Commits between 2021-09-01 and 2023-09-30 | +| --------- | --------------------------- | --------------- | ---------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | +| @zkoppert | 1913 | False | [Sponsor Link](https://github.com/sponsors/zkoppert) | [super-linter/super-linter](https://github.com/super-linter/super-linter/commits?author=zkoppert&since=2021-09-01&until=2023-09-30) | ``` ## Local usage without Docker