Skip to content

Error if diff folder exists, normalize ref path #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions website_diff/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ def main(old, new, diff, selector, index):
logger.remove()
logger.add(sys.stderr, level="INFO")

# Throw error if diff folder already exists
if os.path.exists(diff):
sys.exit(f"ERROR: Diff folder {diff} already exists.")

# copy over the new directory to the diff directory
# also ensure directory doesn't exist before this code runs
# copy the js/css to all subdirs (just brute forcing this for now...)
Expand Down
9 changes: 4 additions & 5 deletions website_diff/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,14 @@ def highlight_links(file, root, add_pages, del_pages, diff_pages):
logger.debug(f"Found link in {file}: {ref}")
logger.debug(f"Parsed link: {url}")
if not bool(url.netloc) and ref[-5:] == '.html':
# this is a relative path to an html file. Find path relative to root
#relative_link_path = os.path.relpath(os.path.normpath(os.path.join(curdir, ref)), diff)
if url.path in diff_pages:
path = os.path.normpath(url.path)
if path in diff_pages:
logger.debug(f"This is a relative path to a diff'd page. Highlighting")
link['class'] = link.get('class', []) + ["link-to-diff"]
elif url.path in add_pages:
elif path in add_pages:
logger.debug(f"This is a relative path to an added page. Highlighting")
link['class'] = link.get('class', []) + ["link-to-add"]
elif url.path in del_pages:
elif path in del_pages:
logger.debug(f"This is a relative path to a deleted page. Highlighting")
link['class'] = link.get('class', []) + ["link-to-del"]
else:
Expand Down