Repository navigation
refactor(utils): dedup backup helpers and document lock/exit conventions - #308
Conversation
backupBeforeWrite, backupRepoWrite, and backupExtrasWrite shared an identical body differing only by anchor and backup-root prefix. Extract backupUnder and keep the three as thin scoped wrappers, so the force:false collision and relative-bail behavior live in one place.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
ChangesBackup helper consolidation
Documentation clarifications
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #308 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 90 90
Lines 3247 3234 -13
Branches 814 810 -4
=========================================
- Hits 3247 3234 -13
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/utils.fs.ts`:
- Around line 103-105: The anchor-escape guard in the relative path validation
is insufficient for cross-drive Windows paths where relative() can return
absolute paths, allowing escape of destRoot via join(). Additionally, the check
for ".." is too broad and rejects valid directory names containing ".." like
"..config". Fix this by adding an isAbsolute() check to reject absolute relative
paths, and tighten the ".." check to only match ".." at path-segment boundaries
(e.g., starts with ".." followed by a path separator or is exactly "..") rather
than any string starting with "..". Update the condition on line 104 to include
the isAbsolute() check and make the ".." validation more precise.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 6dc6b883-07a3-40be-beeb-70873a9461c2
📒 Files selected for processing (1)
src/utils.fs.ts
Note in lockFilePath that the lock is HOME-keyed (pull/push mutate HOME-scoped state) and that a NOMAD_REPO override must not be combined with concurrent default-HOME runs. Note in resumeCmd that its raw process.exit calls are intentional because it is lockless and read-only, and that any future locked/mutating step must switch to die()/NomadFatal.
Tighten backupUnder's anchor-escape guard from a bare startsWith('..') to
a segment-boundary check (rel === '..' or a '..<sep>' prefix), so a
legitimate sibling whose name begins with '..' (e.g. ..config) is backed
up instead of skipped. Add a regression test.
|



backupBeforeWrite,backupRepoWrite, andbackupExtrasWrite(identical bodies differing only by anchor and backup-root prefix) into a singlebackupUndercore, keeping the three as thin scoped wrappers.lockFilePathis HOME-keyed because pull/push mutate HOME-scoped state, with theNOMAD_REPO-override concurrency caveat; andresumeCmd's rawprocess.exitcalls are intentional because it is lockless and read-only.Summary by CodeRabbit
"..", preventing mistaken “unsafe path” treatment.".."-prefixed path segment backup scenario.