diff --git a/codechecker_common/review_status_handler.py b/codechecker_common/review_status_handler.py index 1c46a8f3d9..23e5a7f074 100644 --- a/codechecker_common/review_status_handler.py +++ b/codechecker_common/review_status_handler.py @@ -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? """ @@ -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)