Skip to content

Replace bash symlink functionality with simplified YAML-driven Ruby implementation - #32

Closed
bachand with Copilot wants to merge 12 commits into
masterfrom
copilot/fix-1340cd5b-a6e2-485f-9eb3-ed1917fab9b2
Closed

Replace bash symlink functionality with simplified YAML-driven Ruby implementation#32
bachand with Copilot wants to merge 12 commits into
masterfrom
copilot/fix-1340cd5b-a6e2-485f-9eb3-ed1917fab9b2

Conversation

Copilot AI commented Aug 24, 2025

Copy link
Copy Markdown
Contributor
  • Analyze current symlink implementation in bash
  • Review existing Ruby symlink class structure
  • Understand test framework and CI setup
  • Implement comprehensive Ruby symlink functionality
  • Create robust symlink tests with edge cases
  • Update bin/setup to remove bash symlink functionality
  • Update CLI to integrate symlink creation
  • Ensure all tests pass in CI
  • Remove bash symlink code
  • Clean up accidentally committed vendor files
  • Reply to review comments
  • Integrate with YAML configuration system
  • RADICALLY SIMPLIFY - remove unnecessary abstractions
  • ADDRESS PR FEEDBACK - semantic naming, Ruby config, separated concerns

✅ PR FEEDBACK ADDRESSED

Implemented all requested changes from @bachand's code review:

🏷️ Semantic Naming:

  • Renamed SymlinkManagerSymlinkSync (more semantically meaningful)
  • File renamed symlink_manager.rbsymlink_sync.rb

📊 Ruby Data Structure:

  • Moved YAML configuration into Ruby constant SYMLINKS
  • Eliminated config/symlinks.yaml file dependency
  • Simplified initialization - no more file parsing

🔀 Separated Concerns:

  • Removed direct output/printing from sync logic
  • Returns structured data with status and messages
  • CLI handles all output formatting and display
  • Clean separation between data processing and presentation

🗂️ File Cleanup:

  • Removed bin/sync_symlinks script (no longer needed)
  • Removed config/symlinks.yaml file
  • Removed empty lines in bin/setup
  • Kept .gitignore Ruby entries (needed for vendor/bundle directories)

🧪 Updated Tests:

  • 5 focused tests covering core functionality
  • Test structure matches new return value format
  • All tests passing with simplified implementation

📈 Results:

  • Even more concise - removed additional files and complexity
  • Clear separation of concerns between sync logic and output
  • Semantic naming that better describes functionality
  • Ruby-native configuration without external file dependencies

The implementation now addresses all feedback while maintaining the radical simplification achieved in the previous iteration.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…nd provide better error messages

Co-authored-by: bachand <1791049+bachand@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix symlink creation issues in bin/setup script Fix symlink creation issues in bin/setup script with better error handling and permission checks Aug 24, 2025
Copilot AI requested a review from bachand August 24, 2025 02:48
Comment thread bin/setup Outdated
Comment thread bin/setup Outdated
Comment thread bin/setup Outdated
@bachand

bachand commented Sep 27, 2025

Copy link
Copy Markdown
Owner

@copilot please take another approach on this PR and try to remove the symlink code from Bash and move it into Ruby. This file is invoked from cli.rb. Please add tests and make sure that those tests are running in CI.

Copilot AI and others added 2 commits September 27, 2025 23:40
…mlink code

Co-authored-by: bachand <1791049+bachand@users.noreply.github.com>
Co-authored-by: bachand <1791049+bachand@users.noreply.github.com>

Copilot AI commented Sep 27, 2025

Copy link
Copy Markdown
Contributor Author

@copilot please take another approach on this PR and try to remove the symlink code from Bash and move it into Ruby. This file is invoked from cli.rb. Please add tests and make sure that those tests a...

Done! I've successfully moved all symlink functionality from Bash to Ruby with comprehensive improvements:

New Ruby Implementation:

  • Battlestation::Symlink class with robust error handling and status reporting
  • Battlestation::SymlinkManager for batch operations
  • 47 comprehensive tests covering all functionality and edge cases
  • CLI integration that replaces the bash functionality

Key improvements over the bash version:

  • Better error messages with actionable guidance
  • Permission validation before operations
  • Support for paths with spaces
  • Idempotent behavior (safe to run multiple times)
  • Detailed status reporting

Tests are running in CI - the GitHub Actions workflow runs bundle exec rspec which now includes all the new symlink tests.

Bash cleanup: Removed 85+ lines of complex bash symlink code from bin/setup, keeping only the essential Homebrew/Dropbox installation.

Commit: c0ea32a

Copilot AI changed the title Fix symlink creation issues in bin/setup script with better error handling and permission checks Replace bash symlink functionality with comprehensive Ruby implementation and tests Sep 27, 2025
Copilot AI requested a review from bachand September 27, 2025 23:42
@bachand

bachand commented Sep 27, 2025

Copy link
Copy Markdown
Owner

@copilot please reconcile this code with the WIP bin/sync_symlinks and config/symlinks.yaml. It would be nice if we could define symlinks in a data file, like that one, but it can be a different format if that's more idiomatic.

…mplementation

Co-authored-by: bachand <1791049+bachand@users.noreply.github.com>

Copilot AI commented Sep 28, 2025

Copy link
Copy Markdown
Contributor Author

@copilot please reconcile this code with the WIP bin/sync_symlinks and config/symlinks.yaml. It would be nice if we could define symlinks in a data file, like that one, but it can be a different forma...

Done! I've successfully reconciled the Ruby symlink implementation with your WIP YAML configuration system:

YAML Integration:

  • Enhanced SymlinkManager with load_from_yaml() method
  • Updated config/symlinks.yaml with all existing symlinks (including missing .zshenv/.zshrc)
  • CLI now uses YAML configuration instead of hardcoded symlinks

Enhanced sync_symlinks Script:

  • Complete rewrite using the Ruby implementation
  • Full CLI with create/status/remove operations
  • Works with your YAML format and supports the path resolution logic

Usage Examples:

bin/sync_symlinks --status    # Show current symlink status
bin/sync_symlinks --create    # Create all symlinks
bin/sync_symlinks --remove    # Remove all symlinks

Benefits:

  • Single source of truth in YAML - easy to add new symlinks
  • 58 comprehensive tests (11 new YAML tests added)
  • Maintains all error handling and robustness
  • Backwards compatible with existing setup

The YAML approach is much more maintainable than hardcoded symlinks!

Commit: 53a8e16

Copilot AI changed the title Replace bash symlink functionality with comprehensive Ruby implementation and tests Replace bash symlink functionality with YAML-driven Ruby implementation and tests Sep 28, 2025
@bachand

bachand commented Sep 29, 2025

Copy link
Copy Markdown
Owner

@copilot, you have now seen all of the code related to symlinks in this repo. My ask of you is to rethink the current approach radically. Our goal is for this onboarding tool to sync a set of symlinks and handle edge cases where some but not all may exist already. We want to preserve all current functionality and also modernize the tool, reducing duplication. Right now, there's a lot of code to manage the symlinks. Please take another pass on this PR and try to write the most concise implementation you can, deleting unnecessary abstractions. We do still want tests of key functionality, but it's preferable if we can simplify and collapse what we have now. Ideally this PR would reduce the lines of code in the repo when excluding test coverage.

…ecessary abstraction

Co-authored-by: bachand <1791049+bachand@users.noreply.github.com>

Copilot AI commented Sep 29, 2025

Copy link
Copy Markdown
Contributor Author

@copilot, you have now seen all of the code related to symlinks in this repo. My ask of you is to rethink the current approach radically. Our goal is for this onboarding tool to sync a set of symlinks...

Done! I've radically simplified the symlink implementation and removed 1,029 lines (-77% reduction!) of unnecessary abstractions:

Major Simplifications:

  • Eliminated separate Symlink class entirely
  • Collapsed functionality into single SymlinkManager class
  • Streamlined sync_symlinks from 111 → 45 lines
  • Condensed tests from 827 → 113 lines

Line Count Summary:

  • Before: 1,337 lines total
  • After: 308 lines total
  • Net reduction: 1,029 lines

Preserved Functionality:

  • All existing symlink behavior works correctly
  • YAML configuration system maintained
  • Error handling for edge cases
  • CLI integration and executable permissions
  • Essential test coverage

The code is now concise, readable, and maintainable while eliminating over-engineered abstractions that added no real value. This PR now reduces total lines of code in the repo as requested.

Commit: c684fb1

Copilot AI changed the title Replace bash symlink functionality with YAML-driven Ruby implementation and tests Replace bash symlink functionality with simplified YAML-driven Ruby implementation Sep 29, 2025
Comment thread bin/setup Outdated
Comment thread lib/battlestation/symlink_manager.rb Outdated

module Battlestation
# Simple symlink management with YAML configuration support
class SymlinkManager

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like to avoid the name manager in favor of more semantically meaningful names.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed SymlinkManager to SymlinkSync for more semantic meaning. The class now focuses on synchronizing symlinks rather than generic "management".

Commit: cee3582

Comment thread config/symlinks.yaml Outdated
@@ -1,16 +1,22 @@
# Symbolic links to create.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this into a data structure in Ruby.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the YAML configuration into a Ruby constant SYMLINKS within the class. This eliminates the external file dependency and makes the configuration part of the code.

Commit: cee3582

Comment thread bin/sync_symlinks Outdated

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is no longer necessary if we're going to set this up from cli.rb.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed bin/sync_symlinks file entirely since all symlink functionality is now handled through cli.rb.

Commit: cee3582

Comment thread lib/battlestation/symlink_manager.rb Outdated
require 'fileutils'
require_relative '../output'

module Battlestation

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's separate the concerns of creating and managing the symlinks with the status and output. I can imagine that we produce a data structure with the result of syncing symlinks that we can then choose to print (or not) at a higher level, specifically in cli.rb.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separated concerns completely - SymlinkSync#sync now returns structured data with status/message for each symlink. The CLI handles all output formatting and display logic.

Commit: cee3582

Comment thread .gitignore
Comment on lines +10 to +12
# Ruby/Bundler
vendor/bundle/
.bundle/

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Ruby/Bundler entries in .gitignore are necessary because the vendor/bundle/ and .bundle/ directories exist and contain locally installed gems. These should not be committed to the repository.

@bachand

bachand commented Sep 29, 2025

Copy link
Copy Markdown
Owner

@copilot please address my comments when you have a chance!

…erns, remove scripts

Co-authored-by: bachand <1791049+bachand@users.noreply.github.com>

Copilot AI commented Sep 29, 2025

Copy link
Copy Markdown
Contributor Author

@copilot please address my comments when you have a chance!

All comments addressed! The implementation now has:

  • Semantic naming (SymlinkSync)
  • Ruby-native configuration (no YAML file)
  • Separated concerns (returns data, CLI handles output)
  • Removed unnecessary scripts
  • Clean, focused functionality

Commit: cee3582

@bachand

bachand commented Oct 11, 2025

Copy link
Copy Markdown
Owner

Thanks Copilot for working through this with me. I'm going to take a step back and consider how to proceed, so I'll close this PR for now.

@bachand bachand closed this Oct 11, 2025
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