Commit ca99792
authored
Auto migrate hashicorp to ibm (#189)
* Add automatic HashiCorp to IBM copyright holder migration
- Adds updateLicenseHolder() function to auto-detect and replace HashiCorp copyright holders
- Detects 'HashiCorp, Inc.', 'HashiCorp Inc', and 'HashiCorp' patterns
- Works with all comment styles (Go, Python, Shell, C-style, HTML)
- Preserves existing year information and updates to current format
- Modifies processFile() to attempt holder update for files with existing licenses
- Adds comprehensive test coverage with 14 test cases
- Updates README with automatic migration feature documentation
This feature ensures old HashiCorp headers are automatically caught and updated,
preventing regressions from old PRs or copied code.
* Display files being updated regardless of verbose flag
- Remove verbose flag check so files are always displayed during updates
- Show '(copyright holder updated)' when HashiCorp->IBM migration happens
- Show '(license header added)' when new headers are added
- Improves visibility in both --plan and regular mode
* Fix golangci-lint issues
- Add error check for os.Remove in test to satisfy errcheck linter
- Remove ineffectual assignment to modified variable
* Fix --plan flag to show copyright holder updates and update config
- Add wouldUpdateLicenseHolder() function for dry-run detection of copyright holder changes
- Modify processFile() to check for potential holder updates in checkonly/plan mode
- Add test coverage for wouldUpdateLicenseHolder() function
- Now --plan flag shows both missing headers and files that would have copyright holders updated from HashiCorp to IBM
- Fix golangci-lint issues (errcheck and ineffassign)
- Update .copywrite.hcl copyright_year configuration
- Tested: reduced false positives from 29 to 5 files, correctly shows holder updates
* Fix remaining golangci-lint errcheck issue
- Add error check for tmpfile.Close() in TestWouldUpdateLicenseHolder
* Fix 'is a directory' error in copyright holder migration
- Add isDirectory helper function to check for directories and symlinks to directories
- Use helper in updateLicenseHolder and wouldUpdateLicenseHolder functions
- Resolves issue where filepath.Walk's fi.IsDir() misses symlinks to directories
- Fixes error: 'read path: is a directory' reported in PR feedback
This prevents crashes when processing repositories with symbolic links
that point to directories, such as version directories in test fixtures.
* Add comprehensive test cases for directory skipping bug fix
- Add TestIsDirectory to test helper function for detecting directories and symlinks
- Add TestUpdateLicenseHolderSkipsDirectories to verify updateLicenseHolder skips directories
- Add TestWouldUpdateLicenseHolderSkipsDirectories to verify wouldUpdateLicenseHolder skips directories
- Add TestDirectorySkippingRegressionTest as integration test for the original crash scenario
- Tests cover symlinks to directories which was the root cause of 'is a directory' error
- Ensures the fix in commit 0a3f20d remains stable and prevents future regressions
* Fix golangci-lint errcheck issue in test
Check error return value from tmpfile.Close() in TestIsDirectory to satisfy errcheck linter.1 parent 0be59e7 commit ca99792
4 files changed
Lines changed: 665 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
58 | 73 | | |
59 | 74 | | |
60 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
256 | 266 | | |
| 267 | + | |
257 | 268 | | |
258 | 269 | | |
259 | 270 | | |
260 | 271 | | |
261 | 272 | | |
262 | | - | |
263 | | - | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
264 | 287 | | |
265 | 288 | | |
266 | 289 | | |
| |||
340 | 363 | | |
341 | 364 | | |
342 | 365 | | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
343 | 496 | | |
344 | 497 | | |
345 | 498 | | |
| |||
0 commit comments