diff --git a/swh/loader/svn/ra.py b/swh/loader/svn/ra.py --- a/swh/loader/svn/ra.py +++ b/swh/loader/svn/ra.py @@ -84,7 +84,8 @@ """ split_byte = b" " - filetype, *src = data.split(split_byte) + first_line = data.split(b"\n")[0] + filetype, *src = first_line.split(split_byte) src = split_byte.join(src) return filetype, src diff --git a/swh/loader/svn/tests/test_loader.py b/swh/loader/svn/tests/test_loader.py --- a/swh/loader/svn/tests/test_loader.py +++ b/swh/loader/svn/tests/test_loader.py @@ -1728,3 +1728,53 @@ assert_last_visit_matches( loader.storage, repo_url, status="full", type="svn", ) + + +def test_loader_svn_link_parsing(swh_storage, tmp_path): + # create a repository + repo_path = os.path.join(tmp_path, "tmprepo") + repos.create(repo_path) + repo_url = f"file://{repo_path}" + + # first commit + add_commit( + repo_url, + "Add an executable file and a svn link to it.", + [ + CommitChange( + change_type=CommitChangeType.AddOrUpdate, + path="hello-world", + properties={"svn:executable": "*"}, + data=b"#!/bin/bash\necho Hello World !", + ), + CommitChange( + change_type=CommitChangeType.AddOrUpdate, + path="hello", + properties={"svn:special": "*"}, + data=b"link hello-world", + ), + ], + ) + + # second commit + add_commit( + repo_url, + "Update svn link content", + [ + CommitChange( + change_type=CommitChangeType.AddOrUpdate, + path="hello", + data=b"link hello-world\r\n", + ), + ], + ) + + # instantiate a svn loader checking after each processed revision that + # the repository filesystem it reconstructed does not differ from a subversion + # export of that revision + loader = SvnLoader(swh_storage, repo_url, temp_directory=tmp_path, check_revision=1) + + assert loader.load() == {"status": "eventful"} + assert_last_visit_matches( + loader.storage, repo_url, status="full", type="svn", + )