Skip to content

Ruby feature parity#6

Open
melonamin wants to merge 5 commits intomainfrom
feature/ruby-parity
Open

Ruby feature parity#6
melonamin wants to merge 5 commits intomainfrom
feature/ruby-parity

Conversation

@melonamin
Copy link
Copy Markdown
Owner

Summary

Brings the Go version of try to feature parity with the Ruby version, adding all major features that were missing.

Features Added

  • Git worktree support - try worktree <branch> or try . <branch> creates worktrees from git repos

    • Two modes: TRY_PATH (default with date prefix) and --in-repo (GT-compatible in .worktrees/)
    • Auto-adds .worktrees/ to .gitignore when using --in-repo
  • Directory rename (Ctrl-R) - Rename entries with full text editing support and validation

  • Stricter delete confirmation - Must type "YES" instead of single keypress

  • Batch delete mode (Ctrl-D) - Mark multiple entries for deletion, confirm all at once

  • Text editing shortcuts - Ctrl-A/E (start/end), Ctrl-B/F (backward/forward), Ctrl-K (kill to end), Ctrl-W (delete word)

  • Ctrl-T quick create - Create entry immediately from search buffer or enter input mode

  • try init - Generate shell wrapper for bash/zsh/fish with auto-detection

  • GitLab, Bitbucket, and generic git URL support - Clone from any git host

    • gl:user/repo - GitLab shorthand
    • bb:user/repo - Bitbucket shorthand
    • Generic https:// and git@ URLs

Testing

  • Added comprehensive test suite (main_test.go) covering all URL patterns, config loading, and utilities
  • Added shell-based integration tests (spec/tests/) mirroring Ruby test structure
  • Updated Justfile with test runner

Test plan

  • All unit tests pass (go test ./...)
  • Integration tests pass (spec/tests/runner.sh)
  • Manual testing of TUI features (worktree, rename, batch delete, text editing)
  • Shell wrapper generation tested for bash/zsh/fish

Features added:
- Text editing shortcuts (Ctrl-A/E/B/F/W) in all input modes
- Stricter delete confirmation requiring "YES" instead of single keypress
- Directory rename with Ctrl-R
- Ctrl-T as quick create alias
- Git worktree support with two modes:
  - Default: creates in TRY_PATH with date prefix
  - GT-compatible: --in-repo creates in .worktrees/ inside repo
- Shell init command (try init) for cd integration wrapper

Updated help text and TUI navigation hints.
Unit tests (main_test.go):
- Text editing helpers (insert/delete char/word, cursor movement)
- GitHub URL parsing and repo name extraction
- Path and branch sanitization
- Git repository detection
- Search input validation
- Fuzzy matching/scoring algorithm
- Shell detection and wrapper generation

Integration tests (spec/tests/):
- CLI flags (--help, --version)
- Shell init command
- Git worktree commands
- Clone argument handling
- Select-only mode

Added test targets to Justfile: test, test-unit, test-integration, test-race
Security improvements:
- Add shellEscape() to prevent command injection in shell wrappers
- Add validateRenameName() with comprehensive path traversal protection
- Block null bytes, absolute paths, and special directory names in renames
- Improve sanitizeBranchName() to handle spaces, colons, and collapse dashes

Error handling improvements:
- Show delete errors to user instead of silently failing
- Display real-time rename validation errors in TUI
- Use context.WithTimeout instead of goroutine/channel for git operations
- Use %w for error wrapping to preserve error chains

Code quality:
- Add tests for shellEscape, validateRenameName, and expanded sanitizeBranchName
- Replace custom contains() helper with strings.Contains
- Extract timeout constants for clone and worktree operations
- Ctrl-D now toggles mark on items instead of immediate delete
- Multiple items can be marked before confirming deletion
- Marked items show trash icon and red styling
- Footer shows "DELETE MODE | N marked" when active
- Enter in delete mode triggers batch confirmation
- Esc clears marks without quitting app
- Wrong characters in YES confirmation are ignored (not canceled)
- Fix TRY_SHELL to accept shell names like "bash", "fish", "zsh"
Expand git URL recognition beyond GitHub to support:
- GitLab (https, git@, gl: shorthand)
- Bitbucket (https, git@, bb: shorthand)
- Generic git URLs (https://*.git, git@host:path.git, ssh://)

This brings feature parity with the Ruby version's permissive
git URL handling while maintaining structured pattern matching.
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.

1 participant