Skip to content

fix(sync): derive module name from subdirectory basename#178

Draft
quay-devel wants to merge 3 commits into
LobsterTrap:mainfrom
quay-devel:bugfix/issue-177-sync-subdirectory-name
Draft

fix(sync): derive module name from subdirectory basename#178
quay-devel wants to merge 3 commits into
LobsterTrap:mainfrom
quay-devel:bugfix/issue-177-sync-subdirectory-name

Conversation

@quay-devel

@quay-devel quay-devel commented Jun 4, 2026

Copy link
Copy Markdown

Summary

  • Fix name collision when multiple .lola-req entries share the same git URL but specify different #subdirectory= fragments
  • Derive module name as repo stem + subdirectory leaf (e.g., ai-helpers-dev) instead of URL stem alone when #subdirectory= is present
  • Use fetch_module_as_name() to ensure the on-disk directory matches the derived name

Fixes #177

Root Cause

resolve_and_fetch_module() derived the module name from Path(url_path).stem, which always yields the repo name (e.g., ai-helpers) regardless of #subdirectory=. The second entry found the directory already existed and was silently skipped. Additionally, fetch_module() independently derives directory names from the URL, so even a corrected module_name would be stored under the wrong path.

Changes

src/lola/cli/sync.py:

  • After URL-stem name derivation, append -{subdirectory_leaf} when a subdirectory is specified (e.g., ai-helpers + devai-helpers-dev)
  • Switch from fetch_module() to fetch_module_as_name() so the module is stored under the correct name
  • Remove unused fetch_module import

tests/test_cli_sync.py:

  • 6 regression tests in TestSyncSubdirectoryNameDerivation covering: basic subdirectory, no subdirectory (backward compat), two entries same repo, root /, deep paths, trailing slash
  • Updated existing TestSyncWithGitUrls mocks to match fetch_module_as_name

Test plan

  • Regression test: two entries from same repo with different subdirectories get distinct module names
  • Backward compat: URLs without #subdirectory= still use URL stem
  • Edge cases: root /, deep paths, trailing slashes
  • Full suite: 963/963 passed
  • Linting: ruff check + ruff format clean

Note

This contribution was developed with LLM assistance by the Quay team.

🤖 Generated with Claude Code

When a .lola-req file has multiple entries from the same git repository
with different #subdirectory= fragments, lola sync derived the same
module name from the URL for all entries and silently skipped duplicates.

Two changes to resolve_and_fetch_module():

1. When spec.subdirectory is present and has a non-empty basename, derive
   module_name from Path(spec.subdirectory).name instead of the URL stem.
   Falls back to URL stem for edge cases like #subdirectory=/.

2. Switch from fetch_module() to fetch_module_as_name() so the on-disk
   module directory matches the derived name. This follows the pattern
   already used by _fetch_from_marketplace_quiet().

Examples after fix:
- .git#subdirectory=plugins/dev      → module name 'dev'
- .git#subdirectory=plugins/jira     → module name 'jira'
- .git (no subdirectory)             → module name from URL stem (unchanged)

Fixes LobsterTrap#177

Generated-by: Quay LLM Automation (quay-devel)
@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cacfe23b-1ab5-4382-bee5-97f0eb264ea8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Reverts accidental 644→755 mode change on src/lola/cli/sync.py and
tests/test_cli_sync.py from the previous commit.

Generated-by: Quay LLM Automation (quay-devel)
Combine URL stem with subdirectory basename (e.g., ai-helpers-dev)
instead of using the leaf alone (dev). This avoids cross-repo
collisions where different repos could have identically-named
subdirectories.

Fixes LobsterTrap#177
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.

lola sync: name collision when multiple #subdirectory= entries share the same repo URL

1 participant