Handle case when CONSERVANCY_REPOSITORY isn't set at all
This commit is contained in:
parent
5a8da108b9
commit
cc4be8b010
1 changed files with 4 additions and 3 deletions
|
@ -702,9 +702,10 @@ def parse_repo_relative_path(path: str) -> str:
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
raise argparse.ArgumentTypeError(f'File {path} does not exist.')
|
raise argparse.ArgumentTypeError(f'File {path} does not exist.')
|
||||||
real_path = os.path.realpath(path)
|
real_path = os.path.realpath(path)
|
||||||
repo = os.path.realpath(os.getenv('CONSERVANCY_REPOSITORY'))
|
try:
|
||||||
if not repo:
|
repo = os.path.realpath(os.environ['CONSERVANCY_REPOSITORY'])
|
||||||
raise argparse.ArgumentTypeError('$CONSERVANCY_REPOSITORY is not set.')
|
except KeyError:
|
||||||
|
raise argparse.ArgumentTypeError('$CONSERVANCY_REPOSITORY environment variable is not set.')
|
||||||
if not real_path.startswith(repo):
|
if not real_path.startswith(repo):
|
||||||
raise argparse.ArgumentTypeError(
|
raise argparse.ArgumentTypeError(
|
||||||
f'File {real_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}.'
|
||||||
|
|
Loading…
Add table
Reference in a new issue