Add Symlink Utilities Extraction with Comprehensive Bash Testing#20
Merged
Add Symlink Utilities Extraction with Comprehensive Bash Testing#20
Conversation
- Create lib/symlink-utils.bash with shared symlink management functions - Add maybe_symlink() for safe symlink creation with target validation - Add remove_broken_symlinks() for cleanup of invalid symlinks - Add is_symlink_correct() for symlink target verification - Add get_relative_path() for relative path calculation - Add maybe_symlink_relative() for relative symlinks - Add 19 comprehensive unit tests covering all functions and edge cases - Create bin/install/symlinks.bash installation script using utilities - Add create_dotfiles_symlinks() for complete symlink setup workflow - Add create_config_symlinks() with fd/find fallback for config files - Add create_vscode_symlinks() for VS Code configuration - Add create_yazi_symlinks() for Yazi theme setup - Add verify_symlinks() for symlink validation - Support multiple modes: create, verify, clean - Follow established bash migration pattern with zero shellcheck warnings - All 19 tests pass, demonstrates complete symlink management functionality - Extracts reusable utilities from bin/update/symlinks.zsh - Maintains compatibility while improving error handling and validation
- Make test/setup/test-symlink-utils-bash.bats executable - Required for test runner to properly execute the test file
- Add shellcheck validation to Phase 3 CI enhancement tasks - Include shellcheck CI configuration example with appropriate settings - Update quality gates to enforce shellcheck compliance in CI - Document shellcheck standards and configuration approach - Enhance CI/CD pipeline benefits to include automated code quality This ensures bash script quality is automatically validated in the CI pipeline, catching shell scripting issues before merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
💪 What
Symlink Utilities Extraction: Complete extraction and migration of symlink management functionality from the monolithic
bin/update/symlinks.zshinto reusable bash utilities with comprehensive testing and improved error handling.Files Changed
lib/symlink-utils.bash- Shared symlink utility functions (19 tests, all passing)bin/install/symlinks.bash- Complete symlink installation script using shared utilitiestest/setup/test-symlink-utils-bash.bats- Comprehensive unit tests for all symlink functionsCore Functionality Extracted
Symlink Management:
maybe_symlink()- Safe symlink creation with target validation and directory creationremove_broken_symlinks()- Cleanup utility for invalid/broken symlinksis_symlink_correct()- Verification function for symlink target correctnessget_relative_path()- Cross-platform relative path calculationmaybe_symlink_relative()- Relative symlink creation for portable configurationsInstallation Workflow:
create_dotfiles_symlinks()- Complete workflow for all dotfiles symlinkscreate_config_symlinks()- Automated config directory symlinking with fd/find fallbackcreate_vscode_symlinks()- VS Code configuration managementcreate_yazi_symlinks()- Yazi theme and flavor setupverify_symlinks()- Post-installation validation and verificationEnhanced Features
🤔 Why
Code reusability: The original
bin/update/symlinks.zshcontained useful utility functions that were only available in that specific script. Extracting them allows other installation scripts to use the same reliable symlink management.Better testing: The original script was difficult to test due to its monolithic structure. The extracted utilities have comprehensive unit tests covering all edge cases and error conditions.
Improved maintenance: Separated concerns make the code easier to understand, modify, and debug. The installation script focuses on workflow while utilities handle the mechanics.
Consistency with migration project: Follows the established pattern of bash utilities with comprehensive testing and zero shellcheck warnings.
👀 Usage
Basic symlink creation:
Batch operations:
Integration in other scripts:
👩🔬 How to validate
Run all symlink utility tests:
Test symlink creation workflow:
Test individual utilities:
Verify shellcheck compliance:
shellcheck lib/symlink-utils.bash shellcheck bin/install/symlinks.bash # Both should show no warnings (only info about sourcing)All 19 tests pass, zero shellcheck warnings, maintains complete feature parity with original implementation while adding comprehensive error handling and validation.
🔗 Related links