Commit ebe6c6e
authored
feat(INFRA-3081): add --require-pr-numbers flag for generation-time filtering (#253)
## What is the current state of things and why does it need to change?
Currently, `auto-changelog` includes all commits in the changelog, even
direct commits without PR numbers. For projects following strict
PR-based workflows (like MetaMask Extension), these direct commits
should be excluded to ensure all changelog entries represent reviewed
changes.
## What is the solution your changes offer and how does it work?
### 1. New `--requirePrNumbers` Flag
Adds an opt-in CLI flag that filters out commits without PR numbers at
generation time. Defaults to `false` for backward compatibility.
**Files changed:** `cli.ts`, `update-changelog.ts`, `get-new-changes.ts`
### 2. Graceful 404 Handling for Forked Repos
When running on forked repositories, the tool fetches PR details from
the fork. PRs originating from the upstream repo return 404 errors.
Added `try-catch` to return empty labels instead of crashing.
### 3. HTML Comment Stripping
PR templates often contain HTML comments (`<!-- ... -->`) that were
breaking markdown rendering in changelogs. Added `stripHtmlComments()`
function to clean descriptions.
### 4. `CHANGELOG entry: null` Fix
PRs marked with `CHANGELOG entry: null` were appearing as "Null (#PR)"
due to:
- Trailing whitespace not being trimmed
- Case-sensitive comparison (only matched lowercase `null`)
Fixed by adding `.trim()` and case-insensitive comparison at both check
points.
> **Note:** Fixes 2-4 were discovered during integration testing and are
prerequisites for the `--requirePrNumbers` flag to work correctly in
production environments with forked repos.
## Usage
```bash
yarn auto-changelog update --requirePrNumbers --autoCategorize --useChangelogEntry --useShortPrLink --rc
```
## Testing
Tested with
[consensys-test/metamask-extension-test](https://github.com/consensys-test/metamask-extension-test)
on `release/1100.0.0`:
| Test | Result |
|------|--------|
| PR Commit `feat: test commit with PR for 1100.0.0 (#40)` | ✅
**INCLUDED** |
| Direct Commit `chore: direct commit without PR for 1100.0.0` | ✅
**EXCLUDED** |
| `Null (#PR)` entries | ✅ **NONE** (case-insensitive fix working) |
| [Generated
Changelog](https://github.com/consensys-test/metamask-extension-test/blob/release/1100.0.0-Changelog/CHANGELOG.md)
| ✅ Correct |
### Changelog Excerpt
```markdown
## [1100.0.0]
### Added
- feat: test commit with PR for 1100.0.0 (#40)
- Design upgrades for Confirmations (#38399)
- Fix amount component to be only accept numeric inputs (#38235)
...
```
**Note:** `N/A` and `None` entries still appear (e.g., `N/A (#37810)`)
because these are different strings from `null` - they're valid
descriptions that PRs chose to use.
## References
- Complements duplicate detection work: #2511 parent e12cf19 commit ebe6c6e
4 files changed
+94
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
41 | 49 | | |
42 | 50 | | |
43 | 51 | | |
| |||
50 | 58 | | |
51 | 59 | | |
52 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
53 | 65 | | |
54 | 66 | | |
55 | 67 | | |
| |||
132 | 144 | | |
133 | 145 | | |
134 | 146 | | |
| 147 | + | |
135 | 148 | | |
136 | 149 | | |
137 | 150 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
105 | 109 | | |
106 | 110 | | |
107 | 111 | | |
| |||
121 | 125 | | |
122 | 126 | | |
123 | 127 | | |
| 128 | + | |
124 | 129 | | |
125 | 130 | | |
126 | 131 | | |
| |||
134 | 139 | | |
135 | 140 | | |
136 | 141 | | |
| 142 | + | |
137 | 143 | | |
138 | 144 | | |
139 | 145 | | |
| |||
149 | 155 | | |
150 | 156 | | |
151 | 157 | | |
| 158 | + | |
152 | 159 | | |
153 | 160 | | |
154 | 161 | | |
| |||
357 | 364 | | |
358 | 365 | | |
359 | 366 | | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
360 | 373 | | |
361 | 374 | | |
362 | 375 | | |
| |||
416 | 429 | | |
417 | 430 | | |
418 | 431 | | |
| 432 | + | |
419 | 433 | | |
420 | 434 | | |
421 | 435 | | |
| |||
547 | 561 | | |
548 | 562 | | |
549 | 563 | | |
| 564 | + | |
550 | 565 | | |
551 | 566 | | |
552 | 567 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
64 | 81 | | |
65 | 82 | | |
66 | 83 | | |
| |||
122 | 139 | | |
123 | 140 | | |
124 | 141 | | |
125 | | - | |
| 142 | + | |
126 | 143 | | |
127 | 144 | | |
128 | 145 | | |
129 | | - | |
| 146 | + | |
| 147 | + | |
130 | 148 | | |
131 | 149 | | |
132 | 150 | | |
| |||
141 | 159 | | |
142 | 160 | | |
143 | 161 | | |
144 | | - | |
| 162 | + | |
| 163 | + | |
145 | 164 | | |
146 | 165 | | |
147 | 166 | | |
| |||
233 | 252 | | |
234 | 253 | | |
235 | 254 | | |
| 255 | + | |
236 | 256 | | |
237 | 257 | | |
238 | 258 | | |
| |||
243 | 263 | | |
244 | 264 | | |
245 | 265 | | |
| 266 | + | |
246 | 267 | | |
247 | 268 | | |
248 | 269 | | |
| |||
256 | 277 | | |
257 | 278 | | |
258 | 279 | | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
259 | 284 | | |
260 | | - | |
| 285 | + | |
261 | 286 | | |
262 | 287 | | |
263 | 288 | | |
| |||
266 | 291 | | |
267 | 292 | | |
268 | 293 | | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
269 | 299 | | |
270 | 300 | | |
271 | 301 | | |
| |||
323 | 353 | | |
324 | 354 | | |
325 | 355 | | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
336 | 381 | | |
337 | 382 | | |
338 | 383 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
115 | 119 | | |
116 | 120 | | |
117 | 121 | | |
| |||
140 | 144 | | |
141 | 145 | | |
142 | 146 | | |
| 147 | + | |
143 | 148 | | |
144 | 149 | | |
145 | 150 | | |
| |||
154 | 159 | | |
155 | 160 | | |
156 | 161 | | |
| 162 | + | |
157 | 163 | | |
158 | 164 | | |
159 | 165 | | |
| |||
204 | 210 | | |
205 | 211 | | |
206 | 212 | | |
| 213 | + | |
207 | 214 | | |
208 | 215 | | |
209 | 216 | | |
| |||
0 commit comments