Skip to content

Comments

feat: add --json flag to output worktree list in JSON format#124

Merged
k1LoW merged 1 commit intomainfrom
json
Feb 9, 2026
Merged

feat: add --json flag to output worktree list in JSON format#124
k1LoW merged 1 commit intomainfrom
json

Conversation

@k1LoW
Copy link
Owner

@k1LoW k1LoW commented Feb 9, 2026

ref: #123

This pull request introduces a new feature that adds support for JSON output when listing Git worktrees, along with corresponding tests to ensure correct functionality. The main changes involve implementing the JSON output logic, adding a command-line flag to enable it, and verifying the output in the end-to-end test suite.

New JSON Output Feature:

  • Added a --json flag to the CLI, allowing users to output the list of worktrees in JSON format. [1] [2]
  • Implemented the printJSON function in cmd/json.go to format and print worktree information as JSON, including fields for path, branch, head, bare status, and whether the worktree is current.
  • Modified the listWorktrees function to use printJSON when the --json flag is set.

Testing:

  • Added an end-to-end test case in e2e/basic_test.go to verify that the --json flag outputs correctly structured JSON, checks for the presence and correctness of both main and feature worktrees, and validates field values. [1] [2]

@k1LoW k1LoW self-assigned this Feb 9, 2026
@k1LoW k1LoW added enhancement New feature or request tagpr:minor labels Feb 9, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2026

Code Metrics Report

main (5a55674) #124 (d177b87) +/-
Coverage 37.8% 37.5% -0.4%
Code to Test Ratio 1:2.0 1:2.0 -0.1
Test Execution Time 14s 15s +1s
Details
  |                     | main (5a55674) | #124 (d177b87) |  +/-  |
  |---------------------|----------------|----------------|-------|
- | Coverage            |          37.8% |          37.5% | -0.4% |
  |   Files             |             11 |             12 |    +1 |
  |   Lines             |            871 |            880 |    +9 |
  |   Covered           |            330 |            330 |     0 |
- | Code to Test Ratio  |          1:2.0 |          1:2.0 |  -0.1 |
  |   Code              |           1936 |           1969 |   +33 |
+ |   Test              |           4026 |           4090 |   +64 |
- | Test Execution Time |            14s |            15s |   +1s |

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

Files Coverage +/- Status
cmd/json.go 0.0% 0.0% added
cmd/root.go 0.0% 0.0% modified

Reported by octocov

@k1LoW k1LoW marked this pull request as ready for review February 9, 2026 14:42
@k1LoW k1LoW merged commit 0b43c8a into main Feb 9, 2026
3 checks passed
@k1LoW k1LoW deleted the json branch February 9, 2026 14:44
@github-actions github-actions bot mentioned this pull request Feb 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request tagpr:minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant