Skip to content

fix: Use absolute (relative to repo root) path to supplied filename#1152

Open
mattcen wants to merge 4 commits into
tj:mainfrom
mattcen:absolute-browse-path
Open

fix: Use absolute (relative to repo root) path to supplied filename#1152
mattcen wants to merge 4 commits into
tj:mainfrom
mattcen:absolute-browse-path

Conversation

@mattcen
Copy link
Copy Markdown

@mattcen mattcen commented Aug 8, 2024

If a file is referenced from the subdir of a repository, the script confirms it exists and tacks the filename onto the URL, but doesn't check if the filename provided is relative to the repo root.

I couldn't immediately work out the best way to update the tests to:

  1. Create a temp dir inside the existing temp repo
  2. Create a new temp file within that new dir
  3. Change CWD to the new dir
  4. Run git-browse on that new file with a relative path

If a file is referenced from the subdir of a repository, the script
confirms it exists and tacks the filename onto the URL, but doesn't
check if the filename provided is relative to the repo root.
@github-actions github-actions Bot added the Stale label Apr 18, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 9, 2026

This PR was closed because it has been stalled for 365 days with no activity. Feel free to make a new PR if you wish to continue

@github-actions github-actions Bot closed this May 9, 2026
@spacewander spacewander reopened this May 10, 2026
@spacewander
Copy link
Copy Markdown
Collaborator

@mattcen
Is this PR ready for review?

@github-actions github-actions Bot removed the Stale label May 11, 2026
@mattcen mattcen marked this pull request as ready for review May 12, 2026 22:47
@mattcen
Copy link
Copy Markdown
Author

mattcen commented May 12, 2026

@spacewander happy for review, with the caveat I never worked out how to update tests as per PR description

Comment thread bin/git-browse Outdated
@spacewander
Copy link
Copy Markdown
Collaborator

Looks like we need to update the tests.

@spacewander
Copy link
Copy Markdown
Collaborator

Would you update other test files too?

@mattcen
Copy link
Copy Markdown
Author

mattcen commented May 18, 2026

I could not immediately work out how they worked or how to update them in the time I had available, which is why this wasn't completed when I first opened the PR. I will try to take another look at them, but am not sure how soon that will be; any guidance or suggestions you can provide would be much appreciated.

@spacewander
Copy link
Copy Markdown
Collaborator

Maybe you can change

return file[1:]
to return a full path name like os.path.relpath(file, self._cwd)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants