Skip to content

Commit

Permalink
feat(IDX): allow comments in repo list (#100)
Browse files Browse the repository at this point in the history
* feat(IDX): allow comments in repo list

* update

* try again

* update test case

* Update reusable_workflows/tests/test_data/repo_list.txt

Co-authored-by: Bas van Dijk <[email protected]>

---------

Co-authored-by: Bas van Dijk <[email protected]>
  • Loading branch information
cgundy and basvandijk authored Jan 23, 2025
1 parent 2424cc8 commit f216bbf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
5 changes: 2 additions & 3 deletions reusable_workflows/check_membership/check_external_contrib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
7 changes: 5 additions & 2 deletions reusable_workflows/tests/test_check_external_contrib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
4 changes: 4 additions & 0 deletions reusable_workflows/tests/test_data/repo_list.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
one-repo
another-repo # this comment should be ignored
# this comment should also be ignored
yet-another-repo

0 comments on commit f216bbf

Please sign in to comment.