diff --git a/reusable_workflows/check_membership/check_external_contrib.py b/reusable_workflows/check_membership/check_external_contrib.py index d99a2d9..fdd1d90 100644 --- a/reusable_workflows/check_membership/check_external_contrib.py +++ b/reusable_workflows/check_membership/check_external_contrib.py @@ -15,9 +15,8 @@ def get_repos_open_to_contributions(gh: github3.login) -> List[str]: file_content = download_gh_file(repo, file_path) - # convert .txt file to list - repo_list = file_content.split("\n") - repo_list.remove("") + # convert .txt file to list and strip out comments + repo_list = [line.split("#")[0].strip() for line in file_content.split("\n") if line.split("#")[0].strip()] return repo_list diff --git a/reusable_workflows/tests/test_check_external_contrib.py b/reusable_workflows/tests/test_check_external_contrib.py index 296720f..7710b6e 100644 --- a/reusable_workflows/tests/test_check_external_contrib.py +++ b/reusable_workflows/tests/test_check_external_contrib.py @@ -14,13 +14,16 @@ def test_check_repos_open_to_contributions(): gh = mock.Mock() gh_repo = mock.Mock() file_contents = mock.Mock() - file_contents.decoded.decode.return_value = "one-repo\nanother-repo\n" + repo_list = open( + "reusable_workflows/tests/test_data/repo_list.txt", "r" + ).read() + file_contents.decoded.decode.return_value = repo_list gh_repo.file_contents.return_value = file_contents gh.repository.return_value = gh_repo repo_list = get_repos_open_to_contributions(gh) - assert repo_list == ["one-repo", "another-repo"] + assert repo_list == ["one-repo", "another-repo", "yet-another-repo"] gh.repository.assert_called_with( owner="dfinity", repository="repositories-open-to-contributions" ) diff --git a/reusable_workflows/tests/test_data/repo_list.txt b/reusable_workflows/tests/test_data/repo_list.txt new file mode 100644 index 0000000..67fb8b9 --- /dev/null +++ b/reusable_workflows/tests/test_data/repo_list.txt @@ -0,0 +1,4 @@ +one-repo +another-repo # this comment should be ignored +# this comment should also be ignored +yet-another-repo