@aaronshaf/ger 1.2.10 → 2.0.0
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/.ast-grep/rules/no-as-casting.yml +13 -0
- package/.claude-plugin/plugin.json +22 -0
- package/.github/workflows/ci-simple.yml +53 -0
- package/.github/workflows/ci.yml +171 -0
- package/.github/workflows/claude-code-review.yml +83 -0
- package/.github/workflows/claude.yml +50 -0
- package/.github/workflows/dependency-update.yml +84 -0
- package/.github/workflows/release.yml +166 -0
- package/.github/workflows/security-scan.yml +113 -0
- package/.github/workflows/security.yml +96 -0
- package/.husky/pre-commit +16 -0
- package/.husky/pre-push +25 -0
- package/.lintstagedrc.json +6 -0
- package/.tool-versions +1 -0
- package/CLAUDE.md +105 -0
- package/DEVELOPMENT.md +361 -0
- package/EXAMPLES.md +457 -0
- package/README.md +831 -16
- package/bin/ger +3 -18
- package/biome.json +36 -0
- package/bun.lock +678 -0
- package/bunfig.toml +8 -0
- package/docs/adr/0001-use-effect-for-side-effects.md +65 -0
- package/docs/adr/0002-use-bun-runtime.md +64 -0
- package/docs/adr/0003-store-credentials-in-home-directory.md +75 -0
- package/docs/adr/0004-use-commander-for-cli.md +76 -0
- package/docs/adr/0005-use-effect-schema-for-validation.md +93 -0
- package/docs/adr/0006-use-msw-for-api-mocking.md +89 -0
- package/docs/adr/0007-git-hooks-for-quality.md +94 -0
- package/docs/adr/0008-no-as-typecasting.md +83 -0
- package/docs/adr/0009-file-size-limits.md +82 -0
- package/docs/adr/0010-llm-friendly-xml-output.md +93 -0
- package/docs/adr/0011-ai-tool-strategy-pattern.md +102 -0
- package/docs/adr/0012-build-status-message-parsing.md +94 -0
- package/docs/adr/0013-git-subprocess-integration.md +98 -0
- package/docs/adr/0014-group-management-support.md +95 -0
- package/docs/adr/0015-batch-comment-processing.md +111 -0
- package/docs/adr/0016-flexible-change-identifiers.md +94 -0
- package/docs/adr/0017-git-worktree-support.md +102 -0
- package/docs/adr/0018-auto-install-commit-hook.md +103 -0
- package/docs/adr/0019-sdk-package-exports.md +95 -0
- package/docs/adr/0020-code-coverage-enforcement.md +105 -0
- package/docs/adr/0021-typescript-isolated-declarations.md +83 -0
- package/docs/adr/0022-biome-oxlint-tooling.md +124 -0
- package/docs/adr/README.md +30 -0
- package/docs/prd/README.md +12 -0
- package/docs/prd/architecture.md +325 -0
- package/docs/prd/commands.md +425 -0
- package/docs/prd/data-model.md +349 -0
- package/docs/prd/overview.md +124 -0
- package/index.ts +219 -0
- package/oxlint.json +24 -0
- package/package.json +82 -15
- package/scripts/check-coverage.ts +69 -0
- package/scripts/check-file-size.ts +38 -0
- package/scripts/fix-test-mocks.ts +55 -0
- package/skills/gerrit-workflow/SKILL.md +247 -0
- package/skills/gerrit-workflow/examples.md +572 -0
- package/skills/gerrit-workflow/reference.md +728 -0
- package/src/api/gerrit.ts +696 -0
- package/src/cli/commands/abandon.ts +65 -0
- package/src/cli/commands/add-reviewer.ts +156 -0
- package/src/cli/commands/build-status.ts +282 -0
- package/src/cli/commands/checkout.ts +422 -0
- package/src/cli/commands/comment.ts +460 -0
- package/src/cli/commands/comments.ts +85 -0
- package/src/cli/commands/diff.ts +71 -0
- package/src/cli/commands/extract-url.ts +266 -0
- package/src/cli/commands/groups-members.ts +104 -0
- package/src/cli/commands/groups-show.ts +169 -0
- package/src/cli/commands/groups.ts +137 -0
- package/src/cli/commands/incoming.ts +226 -0
- package/src/cli/commands/init.ts +164 -0
- package/src/cli/commands/mine.ts +115 -0
- package/src/cli/commands/open.ts +57 -0
- package/src/cli/commands/projects.ts +68 -0
- package/src/cli/commands/push.ts +430 -0
- package/src/cli/commands/rebase.ts +52 -0
- package/src/cli/commands/remove-reviewer.ts +123 -0
- package/src/cli/commands/restore.ts +50 -0
- package/src/cli/commands/review.ts +486 -0
- package/src/cli/commands/search.ts +162 -0
- package/src/cli/commands/setup.ts +286 -0
- package/src/cli/commands/show.ts +491 -0
- package/src/cli/commands/status.ts +35 -0
- package/src/cli/commands/submit.ts +108 -0
- package/src/cli/commands/vote.ts +119 -0
- package/src/cli/commands/workspace.ts +200 -0
- package/src/cli/index.ts +53 -0
- package/src/cli/register-commands.ts +659 -0
- package/src/cli/register-group-commands.ts +88 -0
- package/src/cli/register-reviewer-commands.ts +97 -0
- package/src/prompts/default-review.md +86 -0
- package/src/prompts/system-inline-review.md +135 -0
- package/src/prompts/system-overall-review.md +206 -0
- package/src/schemas/config.test.ts +245 -0
- package/src/schemas/config.ts +84 -0
- package/src/schemas/gerrit.ts +681 -0
- package/src/services/commit-hook.ts +314 -0
- package/src/services/config.test.ts +150 -0
- package/src/services/config.ts +250 -0
- package/src/services/git-worktree.ts +342 -0
- package/src/services/review-strategy.ts +292 -0
- package/src/test-utils/mock-generator.ts +138 -0
- package/src/utils/change-id.test.ts +98 -0
- package/src/utils/change-id.ts +63 -0
- package/src/utils/comment-formatters.ts +153 -0
- package/src/utils/diff-context.ts +103 -0
- package/src/utils/diff-formatters.ts +141 -0
- package/src/utils/formatters.ts +85 -0
- package/src/utils/git-commit.test.ts +277 -0
- package/src/utils/git-commit.ts +122 -0
- package/src/utils/index.ts +55 -0
- package/src/utils/message-filters.ts +26 -0
- package/src/utils/review-formatters.ts +89 -0
- package/src/utils/review-prompt-builder.ts +110 -0
- package/src/utils/shell-safety.ts +117 -0
- package/src/utils/status-indicators.ts +100 -0
- package/src/utils/url-parser.test.ts +271 -0
- package/src/utils/url-parser.ts +118 -0
- package/tests/abandon.test.ts +230 -0
- package/tests/add-reviewer.test.ts +579 -0
- package/tests/build-status-watch.test.ts +344 -0
- package/tests/build-status.test.ts +789 -0
- package/tests/change-id-formats.test.ts +268 -0
- package/tests/checkout/integration.test.ts +653 -0
- package/tests/checkout/parse-input.test.ts +55 -0
- package/tests/checkout/validation.test.ts +178 -0
- package/tests/comment-batch-advanced.test.ts +431 -0
- package/tests/comment-gerrit-api-compliance.test.ts +414 -0
- package/tests/comment.test.ts +708 -0
- package/tests/comments.test.ts +323 -0
- package/tests/config-service-simple.test.ts +100 -0
- package/tests/diff.test.ts +419 -0
- package/tests/extract-url.test.ts +517 -0
- package/tests/groups-members.test.ts +256 -0
- package/tests/groups-show.test.ts +323 -0
- package/tests/groups.test.ts +334 -0
- package/tests/helpers/build-status-test-setup.ts +83 -0
- package/tests/helpers/config-mock.ts +27 -0
- package/tests/incoming.test.ts +357 -0
- package/tests/init.test.ts +70 -0
- package/tests/integration/commit-hook.test.ts +246 -0
- package/tests/interactive-incoming.test.ts +173 -0
- package/tests/mine.test.ts +285 -0
- package/tests/mocks/msw-handlers.ts +80 -0
- package/tests/open.test.ts +233 -0
- package/tests/projects.test.ts +259 -0
- package/tests/rebase.test.ts +271 -0
- package/tests/remove-reviewer.test.ts +357 -0
- package/tests/restore.test.ts +237 -0
- package/tests/review.test.ts +135 -0
- package/tests/search.test.ts +712 -0
- package/tests/setup.test.ts +63 -0
- package/tests/show-auto-detect.test.ts +324 -0
- package/tests/show.test.ts +813 -0
- package/tests/status.test.ts +145 -0
- package/tests/submit.test.ts +316 -0
- package/tests/unit/commands/push.test.ts +194 -0
- package/tests/unit/git-branch-detection.test.ts +82 -0
- package/tests/unit/git-worktree.test.ts +55 -0
- package/tests/unit/patterns/push-patterns.test.ts +148 -0
- package/tests/unit/schemas/gerrit.test.ts +85 -0
- package/tests/unit/services/commit-hook.test.ts +132 -0
- package/tests/unit/services/review-strategy.test.ts +349 -0
- package/tests/unit/test-utils/mock-generator.test.ts +154 -0
- package/tests/unit/utils/comment-formatters.test.ts +415 -0
- package/tests/unit/utils/diff-context.test.ts +171 -0
- package/tests/unit/utils/diff-formatters.test.ts +165 -0
- package/tests/unit/utils/formatters.test.ts +411 -0
- package/tests/unit/utils/message-filters.test.ts +227 -0
- package/tests/unit/utils/shell-safety.test.ts +230 -0
- package/tests/unit/utils/status-indicators.test.ts +137 -0
- package/tests/vote.test.ts +317 -0
- package/tests/workspace.test.ts +295 -0
- package/tsconfig.json +36 -5
- package/src/commands/branch.ts +0 -180
- package/src/ger.ts +0 -22
- package/src/types.d.ts +0 -35
- package/src/utils.ts +0 -130
|
@@ -0,0 +1,572 @@
|
|
|
1
|
+
# ger CLI Usage Examples
|
|
2
|
+
|
|
3
|
+
Real-world examples and workflows using the ger CLI tool.
|
|
4
|
+
|
|
5
|
+
## Daily Review Workflow
|
|
6
|
+
|
|
7
|
+
### Morning Review Routine
|
|
8
|
+
|
|
9
|
+
Start your day by checking incoming review requests:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# Check what needs your review
|
|
13
|
+
ger incoming
|
|
14
|
+
|
|
15
|
+
# Show detailed info for each change
|
|
16
|
+
ger show 12345
|
|
17
|
+
ger show 12346
|
|
18
|
+
ger show 12347
|
|
19
|
+
|
|
20
|
+
# Post reviews
|
|
21
|
+
ger comment 12345 -m "LGTM! Nice refactoring."
|
|
22
|
+
ger comment 12346 -m "Please add tests for the new method" --unresolved
|
|
23
|
+
ger comment 12347 -m "+1"
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Checking Your Own Changes
|
|
27
|
+
|
|
28
|
+
Monitor the status of your submitted changes:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# List your open changes
|
|
32
|
+
ger mine
|
|
33
|
+
|
|
34
|
+
# Check build status for each
|
|
35
|
+
ger build-status 12350 --watch
|
|
36
|
+
|
|
37
|
+
# View any comments received
|
|
38
|
+
ger comments 12350
|
|
39
|
+
|
|
40
|
+
# Address feedback with new patchset
|
|
41
|
+
# (make local changes, commit, push)
|
|
42
|
+
git add .
|
|
43
|
+
git commit --amend
|
|
44
|
+
ger push
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Working with Work-in-Progress Changes (Optional)
|
|
48
|
+
|
|
49
|
+
If you want to push changes that aren't ready for review yet, you can use WIP:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Push as WIP (won't notify reviewers)
|
|
53
|
+
ger push --wip
|
|
54
|
+
|
|
55
|
+
# Continue working and updating
|
|
56
|
+
git add .
|
|
57
|
+
git commit --amend
|
|
58
|
+
ger push --wip
|
|
59
|
+
|
|
60
|
+
# When ready for review
|
|
61
|
+
ger push --ready
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Search for WIP changes:
|
|
65
|
+
```bash
|
|
66
|
+
# Find all WIP changes
|
|
67
|
+
ger search "is:wip"
|
|
68
|
+
|
|
69
|
+
# Your WIP changes only
|
|
70
|
+
ger search "owner:self is:wip"
|
|
71
|
+
|
|
72
|
+
# Combine with other filters
|
|
73
|
+
ger search "owner:self is:wip project:my-project"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Advanced Review Workflows
|
|
77
|
+
|
|
78
|
+
### Multi-File Review with Context
|
|
79
|
+
|
|
80
|
+
When reviewing large changes, examine each file individually:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# Get overview
|
|
84
|
+
ger show 12345
|
|
85
|
+
|
|
86
|
+
# Review file by file
|
|
87
|
+
ger diff 12345 --file src/api/client.ts
|
|
88
|
+
ger diff 12345 --file src/api/types.ts
|
|
89
|
+
ger diff 12345 --file tests/api/client.test.ts
|
|
90
|
+
|
|
91
|
+
# Post inline comments
|
|
92
|
+
ger comment 12345 --file src/api/client.ts --line 42 \
|
|
93
|
+
-m "Consider adding error handling for network failures"
|
|
94
|
+
|
|
95
|
+
ger comment 12345 --file src/api/types.ts --line 15 \
|
|
96
|
+
-m "This type should extend BaseResponse" --unresolved
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Team Review Session
|
|
100
|
+
|
|
101
|
+
Coordinate reviews during team sync:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
# List all open changes
|
|
105
|
+
ger open --limit 20
|
|
106
|
+
|
|
107
|
+
# Filter by team member
|
|
108
|
+
ger open --owner alice@example.com
|
|
109
|
+
ger open --owner bob@example.com
|
|
110
|
+
|
|
111
|
+
# Quick status check
|
|
112
|
+
for id in 12345 12346 12347; do
|
|
113
|
+
echo "Change $id:"
|
|
114
|
+
ger build-status $id
|
|
115
|
+
ger comments $id --unresolved-only
|
|
116
|
+
echo "---"
|
|
117
|
+
done
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Managing Team Reviewers with Groups
|
|
121
|
+
|
|
122
|
+
Find and manage reviewer groups for your changes:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
# Find all available groups
|
|
126
|
+
ger groups
|
|
127
|
+
|
|
128
|
+
# Find groups for your project
|
|
129
|
+
ger groups --project my-project
|
|
130
|
+
|
|
131
|
+
# Search for specific team groups
|
|
132
|
+
ger groups --pattern "^team-.*"
|
|
133
|
+
|
|
134
|
+
# View who's in a reviewer group before adding
|
|
135
|
+
ger groups-show project-reviewers
|
|
136
|
+
ger groups-members project-reviewers
|
|
137
|
+
|
|
138
|
+
# Add entire team as reviewers
|
|
139
|
+
ger add-reviewer --group project-reviewers -c 12345
|
|
140
|
+
|
|
141
|
+
# Add admin group as CC for visibility
|
|
142
|
+
ger add-reviewer --group administrators --cc -c 12345
|
|
143
|
+
|
|
144
|
+
# Add multiple groups
|
|
145
|
+
ger add-reviewer --group frontend-team -c 12345
|
|
146
|
+
ger add-reviewer --group backend-team -c 12345
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
**Practical workflow for finding the right reviewers:**
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
# Step 1: Find groups for your project
|
|
153
|
+
ger groups --project canvas-lms --pattern ".*-reviewers"
|
|
154
|
+
|
|
155
|
+
# Step 2: Check who's in the group
|
|
156
|
+
ger groups-show canvas-frontend-reviewers
|
|
157
|
+
|
|
158
|
+
# Step 3: Add the group to your change
|
|
159
|
+
ger add-reviewer --group canvas-frontend-reviewers -c 12345
|
|
160
|
+
|
|
161
|
+
# Step 4: Verify they were added (check the change)
|
|
162
|
+
ger show 12345
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**Automation example - add reviewers based on file changes:**
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
#!/bin/bash
|
|
169
|
+
# auto-add-reviewers.sh
|
|
170
|
+
|
|
171
|
+
CHANGE_ID=$1
|
|
172
|
+
|
|
173
|
+
# Get the list of changed files
|
|
174
|
+
FILES=$(ger diff $CHANGE_ID --files-only)
|
|
175
|
+
|
|
176
|
+
# Add appropriate team based on files
|
|
177
|
+
if echo "$FILES" | grep -q "^src/api/"; then
|
|
178
|
+
ger add-reviewer --group api-team -c $CHANGE_ID
|
|
179
|
+
fi
|
|
180
|
+
|
|
181
|
+
if echo "$FILES" | grep -q "^src/frontend/"; then
|
|
182
|
+
ger add-reviewer --group frontend-team -c $CHANGE_ID
|
|
183
|
+
fi
|
|
184
|
+
|
|
185
|
+
if echo "$FILES" | grep -q "^db/migrations/"; then
|
|
186
|
+
ger add-reviewer --group database-team -c $CHANGE_ID
|
|
187
|
+
fi
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## AI-Assisted Code Review
|
|
191
|
+
|
|
192
|
+
### Using AI for Automated Review
|
|
193
|
+
|
|
194
|
+
Integrate with AI tools for comprehensive code analysis:
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
# Get the diff
|
|
198
|
+
ger diff 12345 > /tmp/change.diff
|
|
199
|
+
|
|
200
|
+
# Run AI analysis
|
|
201
|
+
cat /tmp/change.diff | ai-code-review --model gpt-4 > /tmp/review.txt
|
|
202
|
+
|
|
203
|
+
# Post AI-generated feedback
|
|
204
|
+
cat /tmp/review.txt | ger comment 12345
|
|
205
|
+
|
|
206
|
+
# Or do it all in one pipeline
|
|
207
|
+
ger diff 12345 | ai-code-review --model gpt-4 | ger comment 12345
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Custom AI Review Script
|
|
211
|
+
|
|
212
|
+
Create a wrapper script for consistent AI reviews:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
#!/bin/bash
|
|
216
|
+
# ai-gerrit-review.sh
|
|
217
|
+
|
|
218
|
+
CHANGE_ID=$1
|
|
219
|
+
|
|
220
|
+
# Get change details
|
|
221
|
+
INFO=$(ger show $CHANGE_ID --format json)
|
|
222
|
+
DIFF=$(ger diff $CHANGE_ID)
|
|
223
|
+
|
|
224
|
+
# Create prompt for AI
|
|
225
|
+
PROMPT="Review this code change:
|
|
226
|
+
|
|
227
|
+
Change Info:
|
|
228
|
+
$INFO
|
|
229
|
+
|
|
230
|
+
Diff:
|
|
231
|
+
$DIFF
|
|
232
|
+
|
|
233
|
+
Please provide:
|
|
234
|
+
1. Overall assessment
|
|
235
|
+
2. Potential bugs or issues
|
|
236
|
+
3. Performance concerns
|
|
237
|
+
4. Security considerations
|
|
238
|
+
5. Suggestions for improvement
|
|
239
|
+
"
|
|
240
|
+
|
|
241
|
+
# Get AI review
|
|
242
|
+
REVIEW=$(echo "$PROMPT" | ai-tool analyze)
|
|
243
|
+
|
|
244
|
+
# Post review
|
|
245
|
+
echo "$REVIEW" | ger comment $CHANGE_ID
|
|
246
|
+
|
|
247
|
+
echo "AI review posted to change $CHANGE_ID"
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
Usage:
|
|
251
|
+
```bash
|
|
252
|
+
./ai-gerrit-review.sh 12345
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## CI/CD Integration
|
|
256
|
+
|
|
257
|
+
### Jenkins Build Monitoring
|
|
258
|
+
|
|
259
|
+
Monitor Jenkins builds for Gerrit changes:
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
# Check build status
|
|
263
|
+
ger build-status 12345
|
|
264
|
+
|
|
265
|
+
# Wait for build to complete
|
|
266
|
+
ger build-status 12345 --watch --timeout 1800
|
|
267
|
+
|
|
268
|
+
# Extract build URL
|
|
269
|
+
ger extract-url "build-summary-report" 12345 | tail -1
|
|
270
|
+
|
|
271
|
+
# Complete workflow: wait for build, then extract URL
|
|
272
|
+
ger build-status 12345 --watch --interval 20 --timeout 1800 && \
|
|
273
|
+
ger extract-url "build-summary-report" 12345 | tail -1
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### Automated Build Status Notifications
|
|
277
|
+
|
|
278
|
+
Create a script to monitor builds and notify on completion:
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
#!/bin/bash
|
|
282
|
+
# watch-build.sh
|
|
283
|
+
|
|
284
|
+
CHANGE_ID=$1
|
|
285
|
+
SLACK_WEBHOOK=$2
|
|
286
|
+
|
|
287
|
+
echo "Monitoring build for change $CHANGE_ID..."
|
|
288
|
+
|
|
289
|
+
# Wait for build
|
|
290
|
+
if ger build-status $CHANGE_ID --watch --timeout 3600; then
|
|
291
|
+
STATUS="SUCCESS"
|
|
292
|
+
MESSAGE="Build passed for change $CHANGE_ID"
|
|
293
|
+
else
|
|
294
|
+
STATUS="FAILURE"
|
|
295
|
+
BUILD_URL=$(ger extract-url "build-summary-report" $CHANGE_ID | tail -1)
|
|
296
|
+
MESSAGE="Build failed for change $CHANGE_ID. See: $BUILD_URL"
|
|
297
|
+
fi
|
|
298
|
+
|
|
299
|
+
# Send notification
|
|
300
|
+
curl -X POST -H 'Content-type: application/json' \
|
|
301
|
+
--data "{\"text\":\"$MESSAGE\"}" \
|
|
302
|
+
$SLACK_WEBHOOK
|
|
303
|
+
|
|
304
|
+
echo "$STATUS"
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
## Batch Operations
|
|
308
|
+
|
|
309
|
+
### Review Multiple Changes
|
|
310
|
+
|
|
311
|
+
Process multiple changes efficiently:
|
|
312
|
+
|
|
313
|
+
```bash
|
|
314
|
+
#!/bin/bash
|
|
315
|
+
# batch-review.sh
|
|
316
|
+
|
|
317
|
+
CHANGES=(12345 12346 12347 12348)
|
|
318
|
+
|
|
319
|
+
for CHANGE in "${CHANGES[@]}"; do
|
|
320
|
+
echo "Reviewing change $CHANGE..."
|
|
321
|
+
|
|
322
|
+
# Show change
|
|
323
|
+
ger show $CHANGE
|
|
324
|
+
|
|
325
|
+
# Wait for user input
|
|
326
|
+
read -p "Review comment (or 'skip'): " COMMENT
|
|
327
|
+
|
|
328
|
+
if [ "$COMMENT" != "skip" ]; then
|
|
329
|
+
ger comment $CHANGE -m "$COMMENT"
|
|
330
|
+
echo "Comment posted to $CHANGE"
|
|
331
|
+
fi
|
|
332
|
+
|
|
333
|
+
echo "---"
|
|
334
|
+
done
|
|
335
|
+
|
|
336
|
+
echo "Batch review complete"
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### Abandon Stale Changes
|
|
340
|
+
|
|
341
|
+
Clean up old changes:
|
|
342
|
+
|
|
343
|
+
```bash
|
|
344
|
+
#!/bin/bash
|
|
345
|
+
# abandon-stale.sh
|
|
346
|
+
|
|
347
|
+
# Get your changes (assuming ger mine outputs change IDs)
|
|
348
|
+
CHANGES=$(ger mine --format json | jq -r '.[] | select(.updated < "2024-01-01") | .id')
|
|
349
|
+
|
|
350
|
+
for CHANGE in $CHANGES; do
|
|
351
|
+
echo "Change $CHANGE is stale"
|
|
352
|
+
read -p "Abandon? (y/n): " CONFIRM
|
|
353
|
+
|
|
354
|
+
if [ "$CONFIRM" = "y" ]; then
|
|
355
|
+
ger abandon $CHANGE --message "Abandoning stale change"
|
|
356
|
+
echo "Abandoned $CHANGE"
|
|
357
|
+
fi
|
|
358
|
+
done
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
## Troubleshooting Scenarios
|
|
362
|
+
|
|
363
|
+
### Debugging Failed Builds
|
|
364
|
+
|
|
365
|
+
When a build fails, investigate systematically:
|
|
366
|
+
|
|
367
|
+
```bash
|
|
368
|
+
# Get build status
|
|
369
|
+
ger build-status 12345
|
|
370
|
+
|
|
371
|
+
# Get build summary URL
|
|
372
|
+
BUILD_URL=$(ger extract-url "build-summary-report" 12345 | tail -1)
|
|
373
|
+
|
|
374
|
+
# Post build URL as comment
|
|
375
|
+
ger comment 12345 -m "Build failed. See: $BUILD_URL"
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
### Resolving Merge Conflicts
|
|
379
|
+
|
|
380
|
+
When a change has merge conflicts:
|
|
381
|
+
|
|
382
|
+
```bash
|
|
383
|
+
# Checkout the change
|
|
384
|
+
ger checkout 12345
|
|
385
|
+
|
|
386
|
+
# Rebase onto latest main
|
|
387
|
+
git fetch origin
|
|
388
|
+
git rebase origin/main
|
|
389
|
+
|
|
390
|
+
# Resolve conflicts
|
|
391
|
+
# (edit files, git add, git rebase --continue)
|
|
392
|
+
|
|
393
|
+
# Push updated patchset
|
|
394
|
+
git push origin HEAD:refs/for/main
|
|
395
|
+
|
|
396
|
+
# Notify reviewers
|
|
397
|
+
ger comment 12345 -m "Rebased onto latest main and resolved merge conflicts. Ready for re-review."
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
### Recovery from Accidental Abandon
|
|
401
|
+
|
|
402
|
+
If you accidentally abandoned a change:
|
|
403
|
+
|
|
404
|
+
```bash
|
|
405
|
+
# Note: ger doesn't have restore command yet, use Gerrit UI or API directly
|
|
406
|
+
# This is a placeholder for future functionality
|
|
407
|
+
|
|
408
|
+
# For now, use git to create new change from same commits
|
|
409
|
+
ger checkout 12345
|
|
410
|
+
git push origin HEAD:refs/for/main
|
|
411
|
+
|
|
412
|
+
# Add comment explaining
|
|
413
|
+
ger comment <new-change-id> -m "Re-uploaded change that was accidentally abandoned (was #12345)"
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
## Performance Optimization
|
|
417
|
+
|
|
418
|
+
### Caching Strategies
|
|
419
|
+
|
|
420
|
+
Optimize performance with smart caching:
|
|
421
|
+
|
|
422
|
+
```bash
|
|
423
|
+
# Pre-cache frequently accessed changes
|
|
424
|
+
for id in 12345 12346 12347; do
|
|
425
|
+
ger show $id > /dev/null 2>&1 &
|
|
426
|
+
done
|
|
427
|
+
wait
|
|
428
|
+
|
|
429
|
+
# Now access them quickly (from cache)
|
|
430
|
+
ger show 12345
|
|
431
|
+
ger show 12346
|
|
432
|
+
ger show 12347
|
|
433
|
+
|
|
434
|
+
# Force fresh data when needed
|
|
435
|
+
ger show 12345 --no-cache
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
### Parallel Operations
|
|
439
|
+
|
|
440
|
+
Speed up batch operations with parallelization:
|
|
441
|
+
|
|
442
|
+
```bash
|
|
443
|
+
# Sequential (slow)
|
|
444
|
+
for id in 12345 12346 12347 12348 12349; do
|
|
445
|
+
ger show $id
|
|
446
|
+
done
|
|
447
|
+
|
|
448
|
+
# Parallel (fast)
|
|
449
|
+
for id in 12345 12346 12347 12348 12349; do
|
|
450
|
+
ger show $id &
|
|
451
|
+
done
|
|
452
|
+
wait
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
## Scripting Best Practices
|
|
456
|
+
|
|
457
|
+
### Error Handling
|
|
458
|
+
|
|
459
|
+
Always handle errors in scripts:
|
|
460
|
+
|
|
461
|
+
```bash
|
|
462
|
+
#!/bin/bash
|
|
463
|
+
set -e # Exit on error
|
|
464
|
+
|
|
465
|
+
CHANGE_ID=$1
|
|
466
|
+
|
|
467
|
+
if [ -z "$CHANGE_ID" ]; then
|
|
468
|
+
echo "Error: Change ID required"
|
|
469
|
+
echo "Usage: $0 <change-id>"
|
|
470
|
+
exit 1
|
|
471
|
+
fi
|
|
472
|
+
|
|
473
|
+
# Check if change exists
|
|
474
|
+
if ! ger show $CHANGE_ID > /dev/null 2>&1; then
|
|
475
|
+
echo "Error: Change $CHANGE_ID not found"
|
|
476
|
+
exit 1
|
|
477
|
+
fi
|
|
478
|
+
|
|
479
|
+
# Proceed with operation
|
|
480
|
+
ger diff $CHANGE_ID
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
### JSON Processing
|
|
484
|
+
|
|
485
|
+
Use jq for parsing JSON output:
|
|
486
|
+
|
|
487
|
+
```bash
|
|
488
|
+
# Extract specific fields
|
|
489
|
+
ger show 12345 --format json | jq '.subject'
|
|
490
|
+
ger show 12345 --format json | jq '.owner.email'
|
|
491
|
+
|
|
492
|
+
# Filter comments
|
|
493
|
+
ger comments 12345 --format json | jq '.[] | select(.unresolved == true)'
|
|
494
|
+
|
|
495
|
+
# Get list of changed files
|
|
496
|
+
ger show 12345 --format json | jq -r '.files[].path'
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
### Integration Functions
|
|
500
|
+
|
|
501
|
+
Create reusable functions:
|
|
502
|
+
|
|
503
|
+
```bash
|
|
504
|
+
# Add to ~/.bashrc or ~/.zshrc
|
|
505
|
+
|
|
506
|
+
# Quick review function
|
|
507
|
+
grev() {
|
|
508
|
+
local change_id=$1
|
|
509
|
+
ger show $change_id
|
|
510
|
+
echo ""
|
|
511
|
+
read -p "Comment: " comment
|
|
512
|
+
[ -n "$comment" ] && ger comment $change_id -m "$comment"
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
# Check build and extract URL
|
|
516
|
+
gbuild() {
|
|
517
|
+
local change_id=$1
|
|
518
|
+
ger build-status $change_id --watch && \
|
|
519
|
+
ger extract-url "build-summary-report" $change_id | tail -1
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
# AI review shortcut
|
|
523
|
+
gaireview() {
|
|
524
|
+
local change_id=$1
|
|
525
|
+
ger diff $change_id | ai-review-tool | ger comment $change_id
|
|
526
|
+
}
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
Usage:
|
|
530
|
+
```bash
|
|
531
|
+
grev 12345 # Quick review
|
|
532
|
+
gbuild 12345 # Monitor build
|
|
533
|
+
gaireview 12345 # AI review
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
## Tips and Tricks
|
|
537
|
+
|
|
538
|
+
### Quick Change Navigation
|
|
539
|
+
|
|
540
|
+
```bash
|
|
541
|
+
# Checkout latest incoming change
|
|
542
|
+
ger incoming --format json | jq -r '.[0].id' | xargs ger checkout
|
|
543
|
+
|
|
544
|
+
# Review oldest unreviewed change
|
|
545
|
+
ger incoming --format json | jq -r '.[-1].id' | xargs ger show
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
### Custom Aliases
|
|
549
|
+
|
|
550
|
+
Add to your shell config:
|
|
551
|
+
|
|
552
|
+
```bash
|
|
553
|
+
alias gm='ger mine'
|
|
554
|
+
alias gi='ger incoming'
|
|
555
|
+
alias go='ger open'
|
|
556
|
+
alias gs='ger show'
|
|
557
|
+
alias gd='ger diff'
|
|
558
|
+
alias gc='ger comment'
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
### Output Formatting
|
|
562
|
+
|
|
563
|
+
```bash
|
|
564
|
+
# Compact view
|
|
565
|
+
ger mine --format list | head -5
|
|
566
|
+
|
|
567
|
+
# Detailed table
|
|
568
|
+
ger open --format table
|
|
569
|
+
|
|
570
|
+
# Machine-readable
|
|
571
|
+
ger mine --format json | jq '.'
|
|
572
|
+
```
|