@aaronshaf/ger 2.0.4 → 2.0.5
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 +1 -1
- package/src/cli/commands/mine.ts +1 -0
- package/tests/mine.test.ts +56 -0
package/package.json
CHANGED
package/src/cli/commands/mine.ts
CHANGED
|
@@ -31,6 +31,7 @@ export const mineCommand = (
|
|
|
31
31
|
change_id: change.change_id,
|
|
32
32
|
...(change.updated ? { updated: change.updated } : {}),
|
|
33
33
|
...(change.owner?.name ? { owner: change.owner.name } : {}),
|
|
34
|
+
...(change.labels ? { labels: change.labels } : {}),
|
|
34
35
|
})),
|
|
35
36
|
}
|
|
36
37
|
console.log(JSON.stringify(jsonOutput, null, 2))
|
package/tests/mine.test.ts
CHANGED
|
@@ -125,6 +125,62 @@ describe('mine command', () => {
|
|
|
125
125
|
expect(output).toContain('</changes>')
|
|
126
126
|
})
|
|
127
127
|
|
|
128
|
+
test('should include labels in --json output', async () => {
|
|
129
|
+
const mockChanges: ChangeInfo[] = [
|
|
130
|
+
generateMockChange({
|
|
131
|
+
_number: 12345,
|
|
132
|
+
subject: 'Labeled change',
|
|
133
|
+
labels: {
|
|
134
|
+
'Code-Review': { value: 2 },
|
|
135
|
+
Verified: { value: -1 },
|
|
136
|
+
},
|
|
137
|
+
}),
|
|
138
|
+
]
|
|
139
|
+
|
|
140
|
+
server.use(
|
|
141
|
+
http.get('*/a/changes/', () => {
|
|
142
|
+
return HttpResponse.text(`)]}'\n${JSON.stringify(mockChanges)}`)
|
|
143
|
+
}),
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
const mockConfigLayer = Layer.succeed(ConfigService, createMockConfigService())
|
|
147
|
+
await Effect.runPromise(
|
|
148
|
+
mineCommand({ json: true }).pipe(
|
|
149
|
+
Effect.provide(GerritApiServiceLive),
|
|
150
|
+
Effect.provide(mockConfigLayer),
|
|
151
|
+
),
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
const output = mockConsoleLog.mock.calls.map((call) => call[0]).join('\n')
|
|
155
|
+
const parsed = JSON.parse(output)
|
|
156
|
+
const change = parsed.changes[0]
|
|
157
|
+
expect(change.labels).toBeDefined()
|
|
158
|
+
expect(change.labels['Code-Review'].value).toBe(2)
|
|
159
|
+
expect(change.labels['Verified'].value).toBe(-1)
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
test('should omit labels key in --json output when change has no labels', async () => {
|
|
163
|
+
const mockChanges: ChangeInfo[] = [generateMockChange({ _number: 12345 })]
|
|
164
|
+
|
|
165
|
+
server.use(
|
|
166
|
+
http.get('*/a/changes/', () => {
|
|
167
|
+
return HttpResponse.text(`)]}'\n${JSON.stringify(mockChanges)}`)
|
|
168
|
+
}),
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
const mockConfigLayer = Layer.succeed(ConfigService, createMockConfigService())
|
|
172
|
+
await Effect.runPromise(
|
|
173
|
+
mineCommand({ json: true }).pipe(
|
|
174
|
+
Effect.provide(GerritApiServiceLive),
|
|
175
|
+
Effect.provide(mockConfigLayer),
|
|
176
|
+
),
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
const output = mockConsoleLog.mock.calls.map((call) => call[0]).join('\n')
|
|
180
|
+
const parsed = JSON.parse(output)
|
|
181
|
+
expect(parsed.changes[0].labels).toBeUndefined()
|
|
182
|
+
})
|
|
183
|
+
|
|
128
184
|
test('should handle no changes gracefully', async () => {
|
|
129
185
|
server.use(
|
|
130
186
|
http.get('*/a/changes/', () => {
|