@aaronshaf/ger 3.0.2 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aaronshaf/ger",
3
- "version": "3.0.2",
3
+ "version": "4.0.1",
4
4
  "description": "Gerrit CLI and SDK - A modern CLI tool and TypeScript SDK for Gerrit Code Review, built with Effect-TS",
5
5
  "keywords": [
6
6
  "gerrit",
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: gerrit-workflow
3
- description: Work with Gerrit code reviews using the ger CLI tool. Use when reviewing changes, posting comments, managing patches, or interacting with Gerrit. Covers common workflows like fetching changes, viewing diffs, adding comments, and managing change status.
3
+ description: Work with Gerrit code reviews using the ger CLI tool. Use when reviewing changes, posting comments, managing patches, or interacting with Gerrit. Covers common workflows like fetching changes, viewing diffs, adding comments, voting, managing change status, cherry-picking, and tree worktrees.
4
4
  allowed-tools: Bash, Read, Write, Edit, Grep, Glob
5
5
  ---
6
6
 
@@ -12,6 +12,15 @@ This skill helps you work effectively with Gerrit code reviews using the `ger` C
12
12
 
13
13
  The `ger` CLI tool must be installed and accessible in your PATH. It's available globally if installed from `~/github/ger`.
14
14
 
15
+ ## Output Formats
16
+
17
+ Most commands support `--json` and `--xml` flags:
18
+ - `--json` — Structured JSON for programmatic consumption
19
+ - `--xml` — XML with CDATA-wrapped content, optimized for LLM/AI consumption
20
+ - (default) — Plain text / colored terminal output for humans
21
+
22
+ These are mutually exclusive; using both is an error.
23
+
15
24
  ## Core Commands
16
25
 
17
26
  ### Viewing Changes
@@ -20,228 +29,306 @@ The `ger` CLI tool must be installed and accessible in your PATH. It's available
20
29
  ```bash
21
30
  ger show [change-id]
22
31
  ```
23
- Displays metadata, diff, and all comments for a change. If no change-id is provided, uses the current branch.
32
+ Displays metadata, diff, and all comments. Auto-detects from HEAD commit if omitted.
24
33
 
25
34
  **View specific diff:**
26
35
  ```bash
27
36
  ger diff [change-id]
37
+ ger diff [change-id] --file src/api/client.ts # specific file
28
38
  ```
29
- Get diffs with various formatting options.
30
39
 
31
40
  **View all comments:**
32
41
  ```bash
33
42
  ger comments [change-id]
43
+ ger comments [change-id] --unresolved-only
34
44
  ```
35
- View all comments on a change with context.
36
45
 
37
- ### Managing Changes
46
+ **List changed files:**
47
+ ```bash
48
+ ger files [change-id]
49
+ ger files [change-id] --json
50
+ ```
51
+
52
+ **List reviewers:**
53
+ ```bash
54
+ ger reviewers [change-id]
55
+ ger reviewers [change-id] --xml
56
+ ```
38
57
 
39
- **View your changes:**
58
+ ### Listing Changes
59
+
60
+ **Your open changes:**
40
61
  ```bash
41
62
  ger mine
63
+ ger list
42
64
  ```
43
- List all changes owned by you.
44
65
 
45
- **View incoming changes (review requests):**
66
+ **Changes needing your review (reviewer OR cc'd):**
46
67
  ```bash
47
68
  ger incoming
69
+ ger team
48
70
  ```
49
- List changes that need your review.
50
-
51
- **View open changes:**
71
+ Both query `reviewer:self OR cc:self status:open`. Options:
72
+ - `--all-verified` — Include all verification states (default: open only)
73
+ - `-f, --filter <query>` — Append custom Gerrit query syntax
74
+ - `--status <status>` — Filter by status: open, merged, abandoned
75
+ - `-n, --limit <n>` — Limit number of results (default: 25)
76
+ - `--detailed` — Show detailed info for each change
77
+ - `--json` / `--xml`
78
+
79
+ **General list with options:**
52
80
  ```bash
53
- ger open
81
+ ger list --status merged
82
+ ger list --reviewer # same as incoming
83
+ ger list -n 10 --json
54
84
  ```
55
- List all open changes in the project.
56
85
 
57
- **Abandon a change:**
86
+ **Search with custom query:**
58
87
  ```bash
59
- ger abandon [change-id]
88
+ ger search "owner:self is:wip"
89
+ ger search "project:my-project status:open" -n 10 --xml
60
90
  ```
61
- Mark a change as abandoned.
62
91
 
63
- ### Pushing Changes
92
+ ### Posting Comments and Votes
64
93
 
65
- **Push changes to Gerrit:**
94
+ **Post a comment:**
66
95
  ```bash
67
- ger push
96
+ ger comment [change-id] -m "Your comment"
97
+ echo "Review feedback" | ger comment [change-id] # from stdin
98
+ ger comment [change-id] --file src/api/client.ts --line 42 -m "Inline comment"
68
99
  ```
69
100
 
70
- **Push with options:**
101
+ **Vote on a change:**
71
102
  ```bash
72
- # Push to specific branch
73
- ger push -b main
74
-
75
- # Push with topic
76
- ger push -t my-feature
103
+ ger vote [change-id] Code-Review +2
104
+ ger vote [change-id] Verified -1
105
+ ```
77
106
 
78
- # Push with reviewers
79
- ger push -r alice@example.com -r bob@example.com
107
+ ### Managing Changes
80
108
 
81
- # Push as work-in-progress (WIP)
82
- ger push --wip
109
+ **Abandon / restore:**
110
+ ```bash
111
+ ger abandon [change-id] -m "No longer needed"
112
+ ger restore [change-id]
113
+ ```
83
114
 
84
- # Mark change as ready for review
85
- ger push --ready
115
+ **Submit a change:**
116
+ ```bash
117
+ ger submit [change-id]
118
+ ```
86
119
 
87
- # Combine options
88
- ger push -b main -t feature-auth -r alice@example.com --wip
120
+ **Set WIP / Ready:**
121
+ ```bash
122
+ ger set-wip [change-id]
123
+ ger set-wip [change-id] -m "Still working on tests"
124
+ ger set-ready [change-id]
125
+ ger set-ready [change-id] -m "Ready for review"
89
126
  ```
90
127
 
91
- **WIP Workflow (Optional):**
92
- Work-in-progress changes are useful when you want to push changes that aren't ready for review:
128
+ **Topic:**
93
129
  ```bash
94
- # Push initial work as WIP (won't notify reviewers)
95
- ger push --wip
130
+ ger topic [change-id] # get current topic
131
+ ger topic [change-id] my-topic # set topic
132
+ ger topic [change-id] --delete # delete topic
133
+ ```
96
134
 
97
- # Continue updating (stays WIP)
98
- ger push --wip
135
+ ### Pushing Changes
99
136
 
100
- # Mark ready when done (will notify reviewers)
101
- ger push --ready
137
+ **Push changes to Gerrit:**
138
+ ```bash
139
+ ger push
140
+ ger push -b main -t my-feature -r alice@example.com --wip
102
141
  ```
142
+ Options: `-b`, `-t`, `-r`, `--cc`, `--wip`, `--ready`, `--hashtag`, `--private`, `--dry-run`
103
143
 
104
- **Search for WIP changes:**
105
- ```bash
106
- # Find all WIP changes
107
- ger search "is:wip"
144
+ ### Checkout and Cherry-Pick
108
145
 
109
- # Your WIP changes
110
- ger search "owner:self is:wip"
146
+ **Checkout a change locally:**
147
+ ```bash
148
+ ger checkout 12345
149
+ ger checkout 12345 --revision 3 # specific patchset
111
150
  ```
112
151
 
113
- ### Commenting on Changes
114
-
115
- **Post a comment:**
152
+ **Cherry-pick a change into current branch:**
116
153
  ```bash
117
- ger comment [change-id] -m "Your comment"
154
+ ger cherry 12345
155
+ ger cherry 12345/3 # specific patchset
156
+ ger cherry 12345 --no-commit # stage without committing
157
+ ger cherry 12345 --no-verify # skip pre-commit hooks
158
+ ger cherry https://gerrit.example.com/c/my-project/+/12345
118
159
  ```
119
160
 
120
- **Post comment with piped input (useful for AI integration):**
161
+ ### Rebase
162
+
163
+ **Rebase a change on Gerrit (server-side):**
121
164
  ```bash
122
- echo "Review feedback" | ger comment [change-id]
165
+ ger rebase [change-id]
166
+ ger rebase [change-id] --base <sha-or-change>
167
+ ger rebase [change-id] --allow-conflicts # rebase even with conflicts
168
+ ger rebase [change-id] --json
123
169
  ```
170
+ Auto-detects from HEAD commit if no change-id provided.
171
+
172
+ ### Retrigger CI
124
173
 
125
- **Post inline comments:**
174
+ **Post a CI retrigger comment:**
126
175
  ```bash
127
- ger comment [change-id] --file path/to/file --line 42 -m "Comment on specific line"
176
+ ger retrigger [change-id]
128
177
  ```
178
+ Auto-detects from HEAD. Saves the retrigger comment to config on first use (or configure via `ger setup`).
129
179
 
130
- ## Common Workflows
180
+ ### Build Status
131
181
 
132
- ### Reviewing a Change
182
+ **Check Jenkins build status:**
183
+ ```bash
184
+ ger build-status [change-id]
185
+ ger build-status --watch --interval 20 --timeout 1800
186
+ ger build-status --exit-status # non-zero exit on failure (for scripting)
187
+ ```
133
188
 
134
- 1. **Fetch the change details:**
135
- ```bash
136
- ger show [change-id]
137
- ```
189
+ **Extract build URLs:**
190
+ ```bash
191
+ ger extract-url "build-summary-report"
192
+ ger extract-url "build-summary-report" | tail -1
193
+ ```
138
194
 
139
- 2. **Review the diff:**
140
- ```bash
141
- ger diff [change-id]
142
- ```
195
+ **Canonical CI workflow:**
196
+ ```bash
197
+ ger build-status --watch --interval 20 --timeout 1800 && \
198
+ ger extract-url "build-summary-report" | tail -1 | jk failures --smart --xml
199
+ ```
143
200
 
144
- 3. **Post your review:**
145
- ```bash
146
- ger comment [change-id] -m "LGTM! Great work on the refactoring."
147
- ```
201
+ ### Analytics
148
202
 
149
- ### AI-Assisted Code Review
203
+ **View merged change analytics (year-to-date by default):**
204
+ ```bash
205
+ ger analyze
206
+ ger analyze --start-date 2025-01-01 --end-date 2025-12-31
207
+ ger analyze --repo canvas-lms
208
+ ger analyze --json
209
+ ger analyze --xml
210
+ ger analyze --markdown
211
+ ger analyze --csv
212
+ ger analyze --output report.md # write to file
213
+ ```
214
+ Default start date: January 1 of current year.
150
215
 
151
- Use the ger CLI with AI tools for enhanced code review:
216
+ **Update local cache of merged changes:**
217
+ ```bash
218
+ ger update
219
+ ger update --since 2025-01-01
220
+ ```
152
221
 
153
- 1. **Get the diff:**
154
- ```bash
155
- ger diff [change-id] > /tmp/review.diff
156
- ```
222
+ **View recent failures summary:**
223
+ ```bash
224
+ ger failures
225
+ ger failures --xml
226
+ ```
157
227
 
158
- 2. **Analyze with AI and post comments:**
159
- ```bash
160
- # AI analyzes the diff and generates feedback
161
- ai-tool analyze /tmp/review.diff | ger comment [change-id]
162
- ```
228
+ ### Worktree (tree) Commands
163
229
 
164
- ### Work-in-Progress (WIP) Workflow (Optional)
230
+ Manage git worktrees for reviewing changes in isolation.
165
231
 
166
- If you need to push changes that aren't ready for review, you can use the WIP flag:
232
+ **Setup a worktree for a change:**
233
+ ```bash
234
+ ger tree setup 12345
235
+ ger tree setup 12345:3 # specific patchset
236
+ ger tree setup 12345 --xml
237
+ ```
238
+ Creates worktree at `<repo-root>/.ger/<change-number>/`.
167
239
 
168
- 1. **Start with WIP:**
169
- ```bash
170
- # Make changes
171
- git add .
172
- git commit -m "feat: add new feature"
240
+ **List ger-managed worktrees:**
241
+ ```bash
242
+ ger trees
243
+ ger trees --json
244
+ ```
173
245
 
174
- # Push as WIP (won't notify reviewers)
175
- ger push --wip
176
- ```
246
+ **Rebase a worktree (run from inside the worktree):**
247
+ ```bash
248
+ cd .ger/12345
249
+ ger tree rebase
250
+ ger tree rebase --onto origin/main
251
+ ger tree rebase --interactive # interactive rebase (-i)
252
+ ```
177
253
 
178
- 2. **Continue iterating:**
179
- ```bash
180
- # Make more changes
181
- git add .
182
- git commit --amend
254
+ **Remove a worktree:**
255
+ ```bash
256
+ ger tree cleanup 12345
257
+ ```
183
258
 
184
- # Push updates (stays WIP)
185
- ger push --wip
186
- ```
259
+ ### Groups and Reviewers
187
260
 
188
- 3. **Mark ready when complete:**
189
- ```bash
190
- # Final polish
191
- git add .
192
- git commit --amend
261
+ **Add reviewers:**
262
+ ```bash
263
+ ger add-reviewer user@example.com -c 12345
264
+ ger add-reviewer --group project-reviewers -c 12345
265
+ ger add-reviewer --cc user@example.com -c 12345
266
+ ger add-reviewer --notify none user@example.com -c 12345
267
+ ```
193
268
 
194
- # Mark ready for review (notifies reviewers)
195
- ger push --ready
196
- ```
269
+ **Remove reviewers:**
270
+ ```bash
271
+ ger remove-reviewer user@example.com -c 12345
272
+ ```
197
273
 
198
- 4. **Find WIP changes:**
199
- ```bash
200
- # List all your WIP changes
201
- ger search "owner:self is:wip"
202
- ```
274
+ **List groups:**
275
+ ```bash
276
+ ger groups
277
+ ger groups --pattern "^team-.*"
278
+ ger groups --project canvas-lms
279
+ ger groups --owned
280
+ ```
203
281
 
204
- ## Best Practices
282
+ **Show group details / members:**
283
+ ```bash
284
+ ger groups-show administrators
285
+ ger groups-members project-reviewers
286
+ ```
205
287
 
206
- ### When Reviewing Code
288
+ ### Configuration and Setup
207
289
 
208
- 1. **Always read the full change context** using `ger show` before commenting
209
- 2. **Check all comments** with `ger comments` to avoid duplicate feedback
210
- 3. **Be specific** in your comments - reference file paths and line numbers
211
- 4. **Use constructive language** - focus on improvements, not criticism
290
+ ```bash
291
+ ger setup # interactive first-time setup
292
+ ger config list # list all config
293
+ ger config get gerrit.url
294
+ ger config set gerrit.url https://gerrit.example.com
295
+ ```
212
296
 
213
- ### When Managing Changes
297
+ ## Auto-Detection
214
298
 
215
- 1. **Keep changes focused** - one logical change per Gerrit change
216
- 2. **Respond to comments promptly** - address reviewer feedback
217
- 3. **Use meaningful commit messages** - follow conventional commit format
218
- 4. **Test before submitting** - ensure builds pass before requesting review
219
- 5. **Consider WIP flag (optional)** - use `--wip` for changes not ready for review
299
+ These commands auto-detect the change from the HEAD commit's `Change-Id` footer when no change-id is provided:
300
+ `show`, `build-status`, `topic`, `rebase`, `extract-url`, `diff`, `comments`, `vote`, `retrigger`, `files`, `reviewers`
220
301
 
221
- ## Troubleshooting
302
+ ## Common LLM Workflows
222
303
 
223
- **Change not found:**
224
- - Ensure you're in the correct repository
225
- - Verify the change-id is correct
226
- - Check your Gerrit authentication
304
+ ```bash
305
+ # Review a change
306
+ ger show <id> --xml
307
+ ger diff <id> --xml
308
+ ger comments <id> --xml
227
309
 
228
- **Permission denied:**
229
- - Verify your Gerrit credentials are configured
230
- - Check you have access to the project
231
- - Ensure you're added as a reviewer (for private changes)
310
+ # Post a review
311
+ ger comment <id> -m "..."
312
+ ger vote <id> Code-Review +1
232
313
 
233
- **Build failures:**
234
- - Use `ger build-status` to monitor build progress
235
- - Extract build URLs with `ger extract-url`
236
- - Check build logs for detailed failure information
314
+ # Manage changes
315
+ ger push
316
+ ger checkout <id>
317
+ ger abandon <id>
318
+ ger submit <id>
237
319
 
238
- ## Additional Resources
320
+ # WIP toggle
321
+ ger set-wip <id>
322
+ ger set-ready <id> -m "message"
239
323
 
240
- For more detailed information, see [reference.md](reference.md) for complete command documentation and [examples.md](examples.md) for real-world usage examples.
324
+ # Check CI
325
+ ger build-status <id> --exit-status
326
+ ```
241
327
 
242
328
  ## Notes
243
329
 
244
- - Commands assume you're running from within a Gerrit repository
245
- - Most commands accept an optional change-id; if omitted, they use the current branch
330
+ - Commands run from within a Gerrit repository
331
+ - Most commands accept an optional change-id; if omitted, they use the current branch's HEAD `Change-Id`
246
332
  - The tool uses local SQLite caching for offline-first functionality
247
- - All output supports internationalization via i18next
333
+ - `--xml` is preferred over `--json` for LLM/AI consumption (easier to parse)
334
+ - Numeric change numbers (12345) and full Change-IDs (I1234abc...) are both accepted