Skip to content

Comments

fix: improve error handling in file copy, init output, and worktree lookup#146

Merged
k1LoW merged 1 commit intomainfrom
fix-some
Feb 16, 2026
Merged

fix: improve error handling in file copy, init output, and worktree lookup#146
k1LoW merged 1 commit intomainfrom
fix-some

Conversation

@k1LoW
Copy link
Owner

@k1LoW k1LoW commented Feb 16, 2026

This pull request includes several improvements focused on error handling, code clarity, and shell support. The main changes are enhanced error reporting in file operations and worktree lookups, improved resource management when copying files, and a refactor of the shell initialization logic for better maintainability and PowerShell support.

Error handling and reporting improvements:

  • internal/git/worktree.go: Improved error reporting in FindWorktreeByBranchOrDir by returning detailed errors when failing to get the absolute path or resolve symlinks, instead of silently returning nil.

  • internal/git/copy_file.go, internal/git/copy_file_darwin.go: Changed the signatures of copyFile and copyFileTraditional to named return values and updated the defer out.Close() logic to properly propagate file close errors, ensuring resource management issues are correctly reported. [1] [2] [3] [4]

Shell initialization logic and support:

  • cmd/init.go: Refactored the runInit function to use common variables for shell script output, reducing code duplication. Added improved error handling for unsupported shells and unified logic for all supported shells, including explicit support for PowerShell.

@k1LoW k1LoW self-assigned this Feb 16, 2026
@github-actions
Copy link
Contributor

Code Metrics Report

main (4af4773) #146 (946ec78) +/-
Coverage 35.2% 35.3% +0.1%
Code to Test Ratio 1:2.2 1:2.2 -0.1
Test Execution Time 16s 18s +2s
Details
  |                     | main (4af4773) | #146 (946ec78) |  +/-  |
  |---------------------|----------------|----------------|-------|
+ | Coverage            |          35.2% |          35.3% | +0.1% |
  |   Files             |             13 |             13 |     0 |
  |   Lines             |           1079 |           1078 |    -1 |
+ |   Covered           |            380 |            381 |    +1 |
- | Code to Test Ratio  |          1:2.2 |          1:2.2 |  -0.1 |
  |   Code              |           2341 |           2342 |    +1 |
  |   Test              |           5244 |           5244 |     0 |
- | Test Execution Time |            16s |            18s |   +2s |

Code coverage of files in pull request scope (45.7% → 46.4%)

Files Coverage +/- Status
cmd/init.go 0.0% 0.0% modified
internal/git/copy_file.go 63.6% -1.4% modified
internal/git/worktree.go 50.2% 0.0% modified

Reported by octocov

@k1LoW k1LoW marked this pull request as ready for review February 16, 2026 11:11
@k1LoW k1LoW merged commit 618cc69 into main Feb 16, 2026
3 checks passed
@k1LoW k1LoW deleted the fix-some branch February 16, 2026 11:12
@github-actions github-actions bot mentioned this pull request Feb 16, 2026
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