diff --git a/swh/loader/git/tests/test_utils.py b/swh/loader/git/tests/test_utils.py --- a/swh/loader/git/tests/test_utils.py +++ b/swh/loader/git/tests/test_utils.py @@ -3,6 +3,8 @@ # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information +from random import shuffle + import pytest from swh.loader.git import utils @@ -28,3 +30,30 @@ timestamp = 2 ** exp with pytest.raises(ValueError, match=".*is out of range.*"): utils.check_date_time(timestamp) + + +def test_ignore_branch_name(): + branches = [ + b"HEAD", + b"refs/heads/master", + b"refs/{}", + b"refs/pull/10/head", + b"refs/pull/100/head", + b"refs/pull/xyz/merge", # auto-merged GitHub pull requests filtered out + b"refs/^{}", # Peeled refs filtered out + ] + + # order is not interesting + shuffle(branches) + + actual_branches = [b for b in branches if not utils.ignore_branch_name(b)] + + assert sorted(actual_branches) == sorted( + [ + b"HEAD", + b"refs/heads/master", + b"refs/{}", + b"refs/pull/10/head", + b"refs/pull/100/head", + ] + )