From 8baaec2b1883dc8cdc4ca5900144a5bc9f54179d Mon Sep 17 00:00:00 2001 From: Harrison Date: Wed, 16 Oct 2024 17:26:15 +0100 Subject: [PATCH] fix --- contributors/contributor_stats.py | 4 ++-- contributors/markdown.py | 17 ++++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/contributors/contributor_stats.py b/contributors/contributor_stats.py index 8657787..aca2204 100644 --- a/contributors/contributor_stats.py +++ b/contributors/contributor_stats.py @@ -15,7 +15,7 @@ from typing import List import requests -from dataclasses import dataclass +from dataclasses import dataclass, field @dataclass @@ -38,7 +38,7 @@ class ContributorStats: contribution_count: int commit_url: str sponsor_info: str - organisations: list[str] | None = [] + organisations: list[str] = field(default_factory=list) new_contributor: bool = False diff --git a/contributors/markdown.py b/contributors/markdown.py index 48a2395..9d18e03 100644 --- a/contributors/markdown.py +++ b/contributors/markdown.py @@ -92,12 +92,15 @@ def write_markdown_file( markdown_file.write(f"- Repository: {repository}\n") markdown_file.write("\n") markdown_file.write(summary_table) - for key, t in table.items(): - markdown_file.write(f"## {key}\n") - markdown_file.write(t) - # markdown_file.write( - # "\n _this file was generated by the [Contributors GitHub Action](https://github.com/github/contributors)_\n" - # ) + if len(table) == 1 and 'Independent' in table: + markdown_file.write(table['Independent']) + else: + for key, t in table.items(): + markdown_file.write(f"## {key}\n") + markdown_file.write(t) + markdown_file.write( + "\n _this file was generated by the [Contributors GitHub Action](https://github.com/HCookie/contributors)_\n" + ) def get_summary_table(collaborators, start_date, end_date, total_contributions): @@ -223,7 +226,7 @@ def get_contributor_table( added_to_org: bool = False print(show_organisations_list, collaborator.organisations) - for org in collaborator.organisations: + for org in collaborator.organisations or []: if org in show_organisations_list: organisation_contributors[org].append(row) added_to_org = True