Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9346699
D6391.id23244.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
D6391.id23244.diff
View Options
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,24 @@
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", # PR branch filtered
+ b"refs/pull/100/head", # PR branch filtered
+ b"refs/something/merge", # merge request branch filtered
+ b"refs/^{}", # other branch filtered
+ ]
+
+ # 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/{}"]
+ )
diff --git a/swh/loader/git/utils.py b/swh/loader/git/utils.py
--- a/swh/loader/git/utils.py
+++ b/swh/loader/git/utils.py
@@ -83,14 +83,11 @@
def ignore_branch_name(branch_name: bytes) -> bool:
"""Should the git loader ignore the branch named `branch_name`?"""
- if branch_name.endswith(b"^{}"):
- # Peeled refs make the git protocol explode
- return True
- elif branch_name.startswith(b"refs/pull/") and branch_name.endswith(b"/merge"):
- # We filter-out auto-merged GitHub pull requests
- return True
-
- return False
+ return (
+ branch_name.endswith(b"^{}")
+ or branch_name.startswith(b"refs/pull/")
+ or branch_name.endswith(b"/merge")
+ )
def filter_refs(refs: Dict[bytes, bytes]) -> Dict[bytes, HexBytes]:
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jul 3, 4:22 PM (2 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3231005
Attached To
D6391: Add specific test to the filtering branch function
Event Timeline
Log In to Comment