statement_reconciler: Improve the path matching to handle relative paths and symlinks
This commit is contained in:
parent
9129a4af6a
commit
1473d24d6e
1 changed files with 4 additions and 3 deletions
|
@ -666,12 +666,13 @@ def parse_repo_relative_path(path: str) -> str:
|
|||
"""
|
||||
if not os.path.exists(path):
|
||||
raise argparse.ArgumentTypeError(f'File {path} does not exist.')
|
||||
repo = os.getenv('CONSERVANCY_REPOSITORY')
|
||||
real_path = os.path.realpath(path)
|
||||
repo = os.path.realpath(os.getenv('CONSERVANCY_REPOSITORY'))
|
||||
if not repo:
|
||||
raise argparse.ArgumentTypeError('$CONSERVANCY_REPOSITORY is not set.')
|
||||
if not path.startswith(repo):
|
||||
if not real_path.startswith(repo):
|
||||
raise argparse.ArgumentTypeError(
|
||||
f'File {path} does not share a common prefix with $CONSERVANCY_REPOSITORY {repo}.'
|
||||
f'File {real_path} does not share a common prefix with $CONSERVANCY_REPOSITORY {repo}.'
|
||||
)
|
||||
return path
|
||||
|
||||
|
|
Loading…
Reference in a new issue