Skip to content

Commit

Permalink
Resolve paths when blaming files
Browse files Browse the repository at this point in the history
Both `git check-ignore` and `git blame` will error if run on
a symbolic link, so resolve the path before running them.
  • Loading branch information
tomhughes committed Oct 3, 2024
1 parent 43a9b92 commit e69d9cc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions web/client/codechecker_client/blame_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ def __get_tracking_branch(repo: Repo) -> Optional[str]:
def __get_blame_info(file_path: str):
""" Get blame info for the given file. """
try:
repo = Repo(file_path, search_parent_directories=True)
if repo.ignored(file_path):
real_path = os.path.realpath(file_path)
repo = Repo(real_path, search_parent_directories=True)
if repo.ignored(real_path):
LOG.debug("File %s is an ignored file", file_path)
return None
except InvalidGitRepositoryError:
Expand All @@ -59,7 +60,7 @@ def __get_blame_info(file_path: str):
pass

try:
blame = repo.blame_incremental(repo.head.commit.hexsha, file_path)
blame = repo.blame_incremental(repo.head.commit.hexsha, real_path)

res = {
'version': 'v1',
Expand Down

0 comments on commit e69d9cc

Please sign in to comment.