Skip to content

fix(copy): honor configured directory patterns#173

Merged
helizaga merged 1 commit intomainfrom
fix/copy-include-dirs
Apr 27, 2026
Merged

fix(copy): honor configured directory patterns#173
helizaga merged 1 commit intomainfrom
fix/copy-include-dirs

Conversation

@helizaga
Copy link
Copy Markdown
Collaborator

@helizaga helizaga commented Apr 27, 2026

Summary

  • Make git gtr copy honor configured gtr.copy.includeDirs / gtr.copy.excludeDirs when copying from config.
  • Allow directory-only copy config instead of requiring file patterns.
  • Add dry-run support for directory copies so git gtr copy -n previews without mutating targets.
  • Cover includeDirs, excludeDirs, --all, --from, and dry-run behavior.

Fixes #168.

Testing

  • bats tests/cmd_copy.bats tests/copy_safety.bats
  • bats tests/
  • shellcheck lib/commands/copy.sh lib/copy.sh
  • git diff --check

Summary by CodeRabbit

  • New Features
    • Copy command now supports directory-based include/exclude configurations via Git settings.
    • Added ability to configure which hidden directories (e.g., .zed/, .idea/) to include or exclude during copy operations.
    • Dry-run mode now works with directory copying operations.

@helizaga helizaga requested a review from NatoBoram as a code owner April 27, 2026 21:51
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 1bf9fc7e-0f3f-425c-a809-7ac8e6211671

📥 Commits

Reviewing files that changed from the base of the PR and between d182c32 and 9d17180.

📒 Files selected for processing (3)
  • lib/commands/copy.sh
  • lib/copy.sh
  • tests/cmd_copy.bats

Walkthrough

The git gtr copy command now honors directory-based include/exclude configurations (gtr.copy.includeDirs / gtr.copy.excludeDirs) previously only applied by git gtr new. The copy_directories function gains an optional dry_run parameter, enabling dry-run preview support, and cmd_copy conditionally invokes both pattern-based and directory-based copying logic.

Changes

Cohort / File(s) Summary
Directory-based copy support
lib/commands/copy.sh, lib/copy.sh
Extended cmd_copy to read and process gtr.copy.includeDirs / gtr.copy.excludeDirs configuration alongside patterns. Updated copy_directories signature to accept optional dry_run parameter with conditional logging and dry-run behavior when active.
Test coverage
tests/cmd_copy.bats
Added comprehensive test cases validating directory-based copy behavior with includeDirs/excludeDirs, including --dry-run, --from, and --all flag combinations, with assertions on presence/absence of expected directories in target worktrees.

Sequence Diagram

sequenceDiagram
    actor User
    participant cmd_copy as cmd_copy()
    participant Pattern as copy_patterns()
    participant Directory as copy_directories()
    participant FileSystem as File System

    User->>cmd_copy: Invoke with options (--all, --from, --dry-run)
    cmd_copy->>cmd_copy: Read gtr.copy.include/exclude patterns
    cmd_copy->>cmd_copy: Read gtr.copy.includeDirs/excludeDirs
    
    alt patterns exist
        cmd_copy->>Pattern: Call with patterns, dry_run flag
        Pattern->>FileSystem: Copy matching files (or log dry-run)
        Pattern-->>cmd_copy: Return copied count
    end
    
    alt dir_includes exist
        cmd_copy->>Directory: Call with dir_includes, dry_run flag
        Directory->>FileSystem: Copy matching directories (or log dry-run)
        Directory-->>cmd_copy: Return copied count
    end
    
    cmd_copy-->>User: Output copy summary
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A rabbit hops through directories anew,
With includeDirs finally coming through!
From .zed/ to .idea/ in view,
Both copy and new now dance in sync—
Dry-run preview without a blink! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'fix(copy): honor configured directory patterns' directly addresses the main change: adding support for configured directory patterns in the copy command.
Linked Issues check ✅ Passed The pull request fully implements the requirements from issue #168: it reads gtr.copy.includeDirs/excludeDirs, invokes copy_directories in cmd_copy, handles --dry-run properly, and supports --from and --all options.
Out of Scope Changes check ✅ Passed All changes are directly aligned with issue #168: modifying cmd_copy to call copy_directories, adding dry-run support to copy_directories, and adding test coverage for directory-based copying with includeDirs/excludeDirs.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/copy-include-dirs

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@averyjennings averyjennings left a comment

Choose a reason for hiding this comment

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

Looks good — no blockers found.

@helizaga helizaga merged commit 9d49c4b into main Apr 27, 2026
4 checks passed
@helizaga helizaga deleted the fix/copy-include-dirs branch April 27, 2026 22:48
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.

git gtr copy ignores gtr.copy.includeDirs / gtr.copy.excludeDirs

2 participants