From db5dfd4eff812409354bf493f204ca9232db67db Mon Sep 17 00:00:00 2001 From: Zanie Date: Wed, 25 Oct 2023 19:22:03 -0500 Subject: [PATCH] Loosen linked ranges for format diffs since they are not correct --- python/ruff-ecosystem/ruff_ecosystem/format.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/python/ruff-ecosystem/ruff_ecosystem/format.py b/python/ruff-ecosystem/ruff_ecosystem/format.py index 07f67134f4..29972a6772 100644 --- a/python/ruff-ecosystem/ruff_ecosystem/format.py +++ b/python/ruff-ecosystem/ruff_ecosystem/format.py @@ -218,15 +218,14 @@ def patch_set_with_permalinks(patch_set: PatchSet, repo: ClonedRepository) -> st lines = [] for file_patch in patch_set: for hunk in file_patch: - hunk_link = repo.url_for( - file_patch.path, - hunk.source_start, - hunk.source_start + hunk.source_length, - ) + # Note: The line number is not exact because we formatted the repository for + # a baseline; we can't know the exact line number in the original + # source file. + hunk_link = repo.url_for(file_patch.path, hunk.source_start) hunk_lines = str(hunk).splitlines() # Add a link before the hunk - link_title = file_patch.path + hunk_link.split(file_patch.path)[-1] + link_title = file_patch.path + "~L" + str(hunk.source_start) lines.append(f"{link_title}") # Wrap the contents of the hunk in a diff code block