Skip to content

fix(repo): add REPO_URL=local sentinel to bypass git entirely - #127

Merged
marcinpsk merged 2 commits into
mainfrom
develop
Aug 25, 2026
Merged

fix(repo): add REPO_URL=local sentinel to bypass git entirely#127
marcinpsk merged 2 commits into
mainfrom
develop

Conversation

@marcinpsk

@marcinpsk marcinpsk commented Aug 25, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Added an offline/local repository mode that reads an existing library directly without Git operations.
    • Supports repositories containing device-type, module-type, or rack-type libraries, including partial library layouts.
    • Added validation and clear notices when configured paths or branch settings are incompatible.
  • Documentation

    • Added configuration guidance and Docker/CLI examples for local repository usage.
  • Tests

    • Added coverage for local mode, path validation, read-only access, branch handling, and partial library layouts.

mmguero and others added 2 commits August 25, 2026 17:06
DTLRepo always ran a clone or a fetch, even when REPO_PATH already
held the library contents locally. validate_git_url() rejected the
old 'local' value outright, and even a valid URL still triggered a
real git fetch against the remote on every run.

REPO_URL=local now skips Repo(), clone_from(), and fetch() entirely.
REPO_PATH is used as-is and must already contain device-types/,
module-types/, and rack-types/ (no .git required, and none is used).
… export (#126)

* fix(repo): validate the local library layout and share the check with export

REPO_URL=local only checked that REPO_PATH was a directory. An unrelated or
empty path passed that check, and discover_vendors skips type directories that
are absent, so the run imported nothing and still exited 0.

Export mode already had the check it needed, in
Exporter._verify_repo_available. Both sides now read one definition of what
makes a checkout a library: LIBRARY_TYPE_DIRS and library_dirs_present() in
core/repo.py. The sentinel value moves to LOCAL_REPO_URL in core/config.py,
beside the other REPO_* defaults, so config and repo cannot drift on it.

Local mode still skips validate_repo_path on purpose: that check demands write
access, which a read-only or air-gapped mount cannot give, and no import step
writes to REPO_PATH. A test pins the read-only case.

REPO_BRANCH is ignored under the sentinel, so a run that sets both now says so
through the existing config notice mechanism instead of looking like it checked
the branch out.

Documents the mode in the README and .env.example, including the read-only
Docker mount, which is the case that motivated the sentinel.

* fix(import): treat an absent type root as empty instead of crashing

The layout check accepts any one of device-types/, module-types/, and
rack-types/, matching what export mode already accepted. plan_vendor then
called get_devices() on all three regardless, and get_devices() lists the
directory, so a local checkout holding only some of them raised
FileNotFoundError before importing the types it did hold. A device-types-only
library is the likeliest local layout, and it crashed on module-types.

_parse_vendor_racks already had the guard this needed. It is now
_parse_vendor_files and all three roots go through it, so the guard cannot
apply to one root and not the others again.

The repo mock in test_nb_dt_import pointed at /tmp/devices, /tmp/modules and
/tmp/rack-types, paths that never existed. Nothing stat'd them, so the mock
passed for a filesystem that was not there, which is why this went unseen. It
now points at a real empty library tree, and the tests that matched on those
literal paths match on the directory names instead.

Found by CodeRabbit on #126.
@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 2a432b90-840a-4818-a07c-c3597711edce

📥 Commits

Reviewing files that changed from the base of the PR and between 823663a and 5694aaa.

📒 Files selected for processing (11)
  • .env.example
  • README.md
  • core/config.py
  • core/export.py
  • core/import_run.py
  • core/repo.py
  • tests/test_config.py
  • tests/test_exporter.py
  • tests/test_import_run.py
  • tests/test_nb_dt_import.py
  • tests/test_repo.py

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The change adds REPO_URL=local support for read-only libraries at REPO_PATH. It validates supported library directories, skips Git operations, handles partial library layouts, consolidates vendor file parsing, and documents the configuration.

Changes

Local repository mode

Layer / File(s) Summary
Local mode contract and documentation
.env.example, README.md, core/config.py, tests/test_config.py
Configuration recognizes the local sentinel and reports ignored branches. Documentation adds local and offline usage examples.
Local checkout and library validation
core/repo.py, core/export.py, tests/test_repo.py, tests/test_exporter.py
DTLRepo validates local paths and supported library directories, then reads them without Git operations. Export validation uses the shared directory check.
Vendor file planning for partial libraries
core/import_run.py, tests/test_import_run.py, tests/test_nb_dt_import.py
Vendor planning uses one parser for device, module, and rack roots. Tests cover missing roots, temporary library paths, and updated vendor file expectations.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 5694a

The change adds a local repository sentinel that bypasses Git while preserving repository availability validation; no actionable merge-blocking risk remains beyond normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant Configuration
  participant DTLRepo
  participant LocalLibrary
  participant VendorPlanner
  Configuration->>DTLRepo: Pass local URL and REPO_PATH
  DTLRepo->>LocalLibrary: Validate supported library directory
  DTLRepo->>LocalLibrary: Read files without Git operations
  VendorPlanner->>LocalLibrary: Discover available type roots
  LocalLibrary-->>VendorPlanner: Return vendor files
  VendorPlanner-->>Configuration: Produce type plans
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.45% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 47 functions across 9 files. (2 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding the REPO_URL=local sentinel to bypass Git operations.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 57.45% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 47 functions across 9 files. (2 skipped: 2 unsupported.)

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

@marcinpsk
marcinpsk merged commit c148384 into main Aug 25, 2026
17 checks passed
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