From 9befa2778b84daadfb6b6280b3ed6848538f22e8 Mon Sep 17 00:00:00 2001 From: Artanias <43622365+Artanias@users.noreply.github.com> Date: Sun, 5 Jul 2026 14:00:45 +0300 Subject: [PATCH] fix(github_parser): fix GitHub full URL generation for files. - Change URL generation logic to use `/blob/` for files and `/tree/` for directories; - Fix path construction to use consistent current_path format; - Update test expectations to match new output message. --- pyproject.toml | 2 +- src/webparsers/github_parser.py | 6 +++--- test/auto/functional/test_check.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 935f70f..a5e51ab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "codeplag" -version = "0.6.3" +version = "0.6.4" description = "Code plagiarism searching package." authors = [ { name = "Artyom Semidolin, Dmitry Nikolaev, Alexander Evsikov" } diff --git a/src/webparsers/github_parser.py b/src/webparsers/github_parser.py index 735a3c1..3fbdd86 100644 --- a/src/webparsers/github_parser.py +++ b/src/webparsers/github_parser.py @@ -304,9 +304,6 @@ def _get_files_generator_from_node_list( ) -> Iterator[WorkInfo]: for node in node_list: current_path = f"/{node['path']}" - full_link = ( - f"{_GH_URL}{dir_url.owner}/{dir_url.repo}/tree/{dir_url.branch}/{current_path[2:]}" - ) node_type = node["type"] if node_type == "dir": commit_info = self._get_commit_info( @@ -320,6 +317,9 @@ def _get_files_generator_from_node_list( path=current_path, path_regexp=path_regexp, ) + full_link = ( + f"{_GH_URL}{dir_url.owner}/{dir_url.repo}/blob/{dir_url.branch}{current_path}" + ) if ( node_type != "file" or not self._is_accepted_extension(node["name"]) diff --git a/test/auto/functional/test_check.py b/test/auto/functional/test_check.py index c778dbb..26eef36 100644 --- a/test/auto/functional/test_check.py +++ b/test/auto/functional/test_check.py @@ -92,7 +92,7 @@ def test_compare_cpp_files(cmd: list[str], out: bytes, found_plag: bool): ), ( ["--github-urls", *PY_GITHUB_FILES, PY_GITHUB_DIR], - b"Getting works features from GitHub urls", + b"Getting works features from", False, ), (