Skip to content

core: don't mangle entries that don't start with the configured prefix - #1

Merged
non7top merged 3 commits into
mainfrom
fix/prefix-guard
Jul 16, 2026
Merged

non7top merged 3 commits into
mainfrom
fix/prefix-guard

Conversation

@non7top

@non7top non7top commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Summary

_load_recursive() unconditionally slices len(prefix) characters off
every top-level repo entry not in ignore/packages, even when the
entry doesn't actually start with the configured prefix. With
prefix = '_' set, an entry named bin gets sliced to in and
re-dotted to ~/.in instead of being linked as ~/bin.

This is a long-standing upstream bug, reported multiple times without a
fix landing: jbernard#32, jbernard#53,
jbernard#61, jbernard#73. Still present in the latest
PyPI release (0.6.5).

Guards the strip+re-dot behavior behind an actual startswith(prefix)
check; non-conforming entries now pass through unchanged instead of
being mangled.

Test plan

  • Added test_unprefixed_entry_passthrough, reproducing the exact
    bin -> ~/.in scenario from Prefix handling is wierd jbernard/dotfiles#32
  • Confirmed the new test fails against the pre-fix code (stashed
    the fix, reran, got the expected failure) and passes with it
    restored
  • Full suite: 13 passed, 2 xfailed (the two xfails are
    pre-existing and unrelated to this change)

This same fix is also being opened as a PR upstream against
jbernard/dotfiles.

Previously, _load_recursive() unconditionally sliced len(prefix)
characters off every top-level repo entry not in ignore/packages, even
when the entry didn't actually start with the configured prefix. With
prefix='_' set, an entry named 'bin' would be sliced to 'in' and
re-dotted to '~/.in' instead of being linked as '~/bin'.

Guard the strip+re-dot behavior behind an actual prefix check; entries
that don't start with the configured prefix now pass through unchanged.

Fixes jbernard#32, jbernard#53, jbernard#61, jbernard#73
non7top added 2 commits July 16, 2026 07:35
Both positive (correct symlink created) and negative (the old
mis-stripped target is not created) assertions for:
- an unprefixed entry inside a top-level package
- a nested package (declared as 'parent/child')
Replace the defunct Travis CI setup (targeted Python 2.6/2.7/3.2-3.4,
travis-ci.org domain is long gone) with a working GitHub Actions
workflow running the test suite on the latest stable Python (3.14).

- .github/workflows/test.yml: runs pytest on push/PR/workflow_dispatch
- .github/dependabot.yml: keep GitHub Actions versions current
- requirements-test.txt: formalize pytest as the test dependency
- README: swap the dead Travis badge for the new Actions badge
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.

1 participant