You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix swap-deps to handle missing reference directories gracefully (#64)
* Fix swap-deps to handle missing reference directories gracefully
Previously, swap-deps would fail with an error if a local path reference
in .swap-deps.yml or specified on the command line didn't exist. This was
problematic in Conductor workflows where workspace directories and branches
are frequently deleted after merging.
Changes:
- Modified validate_local_paths! to show warnings instead of raising errors
for missing directories
- Updated swap_gemfile, swap_package_json, and build_local_packages! to skip
missing paths with informative messages
- GitHub-managed repos are excluded from validation (they're cloned on demand)
- Updated tests to reflect new warning behavior instead of error raising
- Fixed test stubs to allow additional File.exist? calls for git branch detection
This allows the tool to gracefully handle stale references and continue
processing other valid dependencies.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Allow re-swapping between different paths and branches
Previously, swap-deps would skip gems that were already swapped (had path:
or github: in the Gemfile). This prevented updating to a different local
path or switching between branches after a branch was deleted.
Changes:
- Modified swap_gem_in_gemfile to replace existing path: or github:
references instead of skipping them
- Modified swap_gem_to_github to replace existing path:, github:, branch:,
and tag: references
- Both methods now preserve other gem options (like require: false) when
re-swapping
- Added comprehensive tests for re-swapping scenarios:
* Path to different path
* GitHub branch to different branch
* Path to GitHub branch
* GitHub branch to path
* Preserving options during re-swap
This enables workflows where developers switch between different Conductor
workspace directories or GitHub branches, even when the previous reference
no longer exists.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Address code review feedback
Changes:
- Added clarifying comments about github_repos precedence in validate_local_paths!
GitHub repos take precedence and overwrite gem_paths entries after cloning
- Standardized skip message format across all methods:
* swap_gemfile: "⊘ Skipping {gem} - path does not exist: {path}"
* swap_package_json: "⊘ Skipping {gem} npm package - path does not exist: {path}"
* build_local_packages!: "⊘ Skipping {gem} build - path does not exist: {path}"
- Added integration test verifying validate_local_paths! warns and subsequent
swap operations skip with appropriate messages
- Updated comments to clarify that users are warned BEFORE skip messages appear
All 91 tests pass.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Fix critical issue: Add git: and ref: to regex stripping
Problem: When swapping from gems using git: urls (e.g.,
gem 'name', git: 'url', ref: 'sha'), the git: and ref: parameters
were not being removed, resulting in invalid Gemfile entries like:
gem 'name', path: '/path', git: 'url', ref: 'sha'
This would cause Bundler parsing errors.
Changes:
- Added git: and ref: removal to swap_gem_in_gemfile regex substitutions
- Added git: and ref: removal to swap_gem_to_github regex substitutions
- Updated comments to reflect all source specification parameters are removed
- Added 7 comprehensive test cases:
* Swapping from git: url with ref: to path
* Swapping from git: url without ref: to path
* Swapping from git: url with branch: to path
* Swapping from git: url with ref: and options to path (preserving options)
* Swapping from git: url with ref: to github
* Swapping from git: url with branch: to github
* Swapping from git: url with ref: and options to github (preserving options)
All 98 tests pass.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Refactor and improve code quality based on review feedback
1. Extract Duplicate Regex Stripping (DRY Principle)
- Created strip_gem_source_params helper method to eliminate code duplication
- Removes: version, path, github, git, branch, tag, ref parameters
- Returns empty string if only whitespace remains, or options with leading comma
- Fixes edge case: trailing commas from empty options after stripping
2. Add Swap Summary Output
- Tracks skipped gems in @skipped_gems array
- New print_swap_summary method shows:
* Number of successfully swapped gems (with names)
* Number of skipped gems due to missing paths (with names)
- Makes silent skip behavior more visible to users
3. Comprehensive Integration Test
- Added test for mixed valid/invalid paths scenario
- Verifies:
* Validation warns only about invalid paths
* Valid paths are processed correctly
* Invalid paths are skipped with appropriate messages
* Gemfile content reflects only valid swaps
All 99 tests pass.
Benefits:
- Reduced maintenance burden (single source of truth for regex patterns)
- Better user visibility into what was swapped vs skipped
- More robust test coverage for real-world scenarios
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
---------
Co-authored-by: Claude <[email protected]>
0 commit comments