Skip to content

Commit

Permalink
Fix remote server path resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
vodorok committed Dec 13, 2023
1 parent bea15d4 commit 46c68d6
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions codechecker_common/review_status_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ReviewStatusHandler:
'review_status',
'reason']

def __init__(self, source_root=''):
def __init__(self, source_root=""):
"""
TODO: What happens if multiple report directories are stored?
"""
Expand Down Expand Up @@ -316,15 +316,26 @@ def get_review_status_from_source(
logic where we take the first comment into account in case of ambiguity
or return "unreviewed" with a warning, like changed files.
"""
# The original file path is needed here, not the trimmed, because
# the source files are extracted as the original file path.
# TODO: Should original_path be strip('/') at store?
if self.__source_root:
# The source files are extracted in the same directory tree, under
# a temporary directory. This is why we need to strip the leading
# slash to be able to join the temporary directory with the
# original file path strucutre.
original_path = report.file.original_path.lstrip('/')
else:
# in this branch we are operating on the original filesystem,
# and we need the path to he original file
original_path = report.file.original_path

source_file_name = os.path.realpath(os.path.join(
self.__source_root, report.file.original_path))
self.__source_root, original_path))

if source_file_name in report.changed_files:
return None

if not os.path.exists(source_file_name):
LOG.error(f"Source file '{source_file_name}' does not exist.")

if os.path.isfile(source_file_name):
src_comment_data = self.__parse_codechecker_review_comment(
source_file_name, report.line, report.checker_name)
Expand Down

0 comments on commit 46c68d6

Please sign in to comment.