|
313 | 313 | expect(e).to be_a CodeOwnership::InvalidCodeOwnershipConfigurationError |
314 | 314 | puts e.message |
315 | 315 | expect(e.message).to eq <<~EXPECTED.chomp |
316 | | - CODEOWNERS out of date. Ensure pre-commit hook is set up correctly and used. You can also run bin/codeownership validate to update the CODEOWNERS file |
| 316 | + CODEOWNERS out of date. Run `bin/codeownership validate` to update the CODEOWNERS file |
317 | 317 |
|
318 | 318 | See https://github.com/bigrails/code_ownership#README.md for more details |
319 | 319 | EXPECTED |
|
332 | 332 | expect(e).to be_a CodeOwnership::InvalidCodeOwnershipConfigurationError |
333 | 333 | puts e.message |
334 | 334 | expect(e.message).to eq <<~EXPECTED.chomp |
335 | | - CODEOWNERS out of date. Ensure pre-commit hook is set up correctly and used. You can also run bin/codeownership validate to update the CODEOWNERS file |
| 335 | + CODEOWNERS out of date. Run `bin/codeownership validate` to update the CODEOWNERS file |
336 | 336 |
|
337 | 337 | See https://github.com/bigrails/code_ownership#README.md for more details |
338 | 338 | EXPECTED |
|
357 | 357 | expect(e).to be_a CodeOwnership::InvalidCodeOwnershipConfigurationError |
358 | 358 | puts e.message |
359 | 359 | expect(e.message).to eq <<~EXPECTED.chomp |
360 | | - CODEOWNERS out of date. Ensure pre-commit hook is set up correctly and used. You can also run bin/codeownership validate to update the CODEOWNERS file |
| 360 | + CODEOWNERS out of date. Run `bin/codeownership validate` to update the CODEOWNERS file |
361 | 361 |
|
362 | 362 | See https://github.com/bigrails/code_ownership#README.md for more details |
363 | 363 | EXPECTED |
|
386 | 386 | expect(e).to be_a CodeOwnership::InvalidCodeOwnershipConfigurationError |
387 | 387 | puts e.message |
388 | 388 | expect(e.message).to eq <<~EXPECTED.chomp |
389 | | - CODEOWNERS out of date. Ensure pre-commit hook is set up correctly and used. You can also run bin/codeownership validate to update the CODEOWNERS file |
| 389 | + CODEOWNERS out of date. Run `bin/codeownership validate` to update the CODEOWNERS file |
390 | 390 |
|
391 | 391 | See https://github.com/bigrails/code_ownership#README.md for more details |
392 | 392 | EXPECTED |
|
395 | 395 | end |
396 | 396 | end |
397 | 397 | end |
| 398 | + |
| 399 | + context 'in an application with a CODEOWNERS file that is missing lines and has extra lines' do |
| 400 | + before { create_non_empty_application } |
| 401 | + |
| 402 | + it 'prints out the diff' do |
| 403 | + FileUtils.mkdir('.github') |
| 404 | + Pathname.new('.github/CODEOWNERS').write <<~CODEOWNERS |
| 405 | + # STOP! - DO NOT EDIT THIS FILE MANUALLY |
| 406 | + # This file was automatically generated by "bin/codeownership validate". |
| 407 | + # |
| 408 | + # CODEOWNERS is used for GitHub to suggest code/file owners to various GitHub |
| 409 | + # teams. This is useful when developers create Pull Requests since the |
| 410 | + # code/file owner is notified. Reference GitHub docs for more details: |
| 411 | + # https://help.github.com/en/articles/about-code-owners |
| 412 | +
|
| 413 | +
|
| 414 | + # Annotations at the top of file |
| 415 | + /frontend/javascripts/packages/my_package/owned_file.jsx @MyOrg/bar-team |
| 416 | + /frontend/some/extra/line/that/should/not/exist @MyOrg/bar-team |
| 417 | +
|
| 418 | + # Team-specific owned globs |
| 419 | + /app/services/bar_stuff/** @MyOrg/bar-team |
| 420 | + /frontend/javascripts/bar_stuff/** @MyOrg/bar-team |
| 421 | +
|
| 422 | + # Some extra comment that should not be here |
| 423 | +
|
| 424 | + # Owner metadata key in package.json |
| 425 | + /frontend/javascripts/packages/my_other_package/**/** @MyOrg/bar-team |
| 426 | + CODEOWNERS |
| 427 | + |
| 428 | + expect_any_instance_of(codeowners_validation).to_not receive(:`) # rubocop:disable RSpec/AnyInstance |
| 429 | + expect { CodeOwnership.validate!(autocorrect: false) }.to raise_error do |e| |
| 430 | + expect(e).to be_a CodeOwnership::InvalidCodeOwnershipConfigurationError |
| 431 | + puts e.message |
| 432 | + expect(e.message).to eq <<~EXPECTED.chomp |
| 433 | + CODEOWNERS out of date. Run `bin/codeownership validate` to update the CODEOWNERS file |
| 434 | +
|
| 435 | + CODEOWNERS should contain the following lines, but does not: |
| 436 | + - "" |
| 437 | + - "/packs/my_pack/owned_file.rb @MyOrg/bar-team" |
| 438 | + - "# Owner metadata key in package.yml" |
| 439 | + - "/packs/my_other_package/**/** @MyOrg/bar-team" |
| 440 | + - "" |
| 441 | +
|
| 442 | + CODEOWNERS should not contain the following lines, but it does: |
| 443 | + - "/frontend/some/extra/line/that/should/not/exist @MyOrg/bar-team" |
| 444 | + - "# Some extra comment that should not be here" |
| 445 | +
|
| 446 | + See https://github.com/bigrails/code_ownership#README.md for more details |
| 447 | + EXPECTED |
| 448 | + end |
| 449 | + end |
| 450 | + end |
| 451 | + |
| 452 | + context 'in an application with a CODEOWNERS file that has extra lines' do |
| 453 | + before { create_non_empty_application } |
| 454 | + |
| 455 | + it 'prints out the diff' do |
| 456 | + FileUtils.mkdir('.github') |
| 457 | + Pathname.new('.github/CODEOWNERS').write <<~CODEOWNERS |
| 458 | + # STOP! - DO NOT EDIT THIS FILE MANUALLY |
| 459 | + # This file was automatically generated by "bin/codeownership validate". |
| 460 | + # |
| 461 | + # CODEOWNERS is used for GitHub to suggest code/file owners to various GitHub |
| 462 | + # teams. This is useful when developers create Pull Requests since the |
| 463 | + # code/file owner is notified. Reference GitHub docs for more details: |
| 464 | + # https://help.github.com/en/articles/about-code-owners |
| 465 | +
|
| 466 | +
|
| 467 | + # Annotations at the top of file |
| 468 | + /frontend/javascripts/packages/my_package/owned_file.jsx @MyOrg/bar-team |
| 469 | + /packs/my_pack/owned_file.rb @MyOrg/bar-team |
| 470 | + /frontend/some/extra/line/that/should/not/exist @MyOrg/bar-team |
| 471 | +
|
| 472 | + # Team-specific owned globs |
| 473 | + /app/services/bar_stuff/** @MyOrg/bar-team |
| 474 | + /frontend/javascripts/bar_stuff/** @MyOrg/bar-team |
| 475 | +
|
| 476 | + # Owner metadata key in package.yml |
| 477 | + /packs/my_other_package/**/** @MyOrg/bar-team |
| 478 | +
|
| 479 | + # Some extra comment that should not be here |
| 480 | +
|
| 481 | + # Owner metadata key in package.json |
| 482 | + /frontend/javascripts/packages/my_other_package/**/** @MyOrg/bar-team |
| 483 | +
|
| 484 | + CODEOWNERS |
| 485 | + |
| 486 | + expect_any_instance_of(codeowners_validation).to_not receive(:`) # rubocop:disable RSpec/AnyInstance |
| 487 | + expect { CodeOwnership.validate!(autocorrect: false) }.to raise_error do |e| |
| 488 | + expect(e).to be_a CodeOwnership::InvalidCodeOwnershipConfigurationError |
| 489 | + puts e.message |
| 490 | + expect(e.message).to eq <<~EXPECTED.chomp |
| 491 | + CODEOWNERS out of date. Run `bin/codeownership validate` to update the CODEOWNERS file |
| 492 | +
|
| 493 | + CODEOWNERS should not contain the following lines, but it does: |
| 494 | + - "/frontend/some/extra/line/that/should/not/exist @MyOrg/bar-team" |
| 495 | + - "# Some extra comment that should not be here" |
| 496 | +
|
| 497 | + See https://github.com/bigrails/code_ownership#README.md for more details |
| 498 | + EXPECTED |
| 499 | + end |
| 500 | + end |
| 501 | + end |
| 502 | + |
| 503 | + context 'in an application with a CODEOWNERS file that has missing lines' do |
| 504 | + before { create_non_empty_application } |
| 505 | + |
| 506 | + it 'prints out the diff' do |
| 507 | + FileUtils.mkdir('.github') |
| 508 | + Pathname.new('.github/CODEOWNERS').write <<~CODEOWNERS |
| 509 | + # STOP! - DO NOT EDIT THIS FILE MANUALLY |
| 510 | + # This file was automatically generated by "bin/codeownership validate". |
| 511 | + # |
| 512 | + # CODEOWNERS is used for GitHub to suggest code/file owners to various GitHub |
| 513 | + # teams. This is useful when developers create Pull Requests since the |
| 514 | + # code/file owner is notified. Reference GitHub docs for more details: |
| 515 | + # https://help.github.com/en/articles/about-code-owners |
| 516 | +
|
| 517 | +
|
| 518 | + # Annotations at the top of file |
| 519 | + /frontend/javascripts/packages/my_package/owned_file.jsx @MyOrg/bar-team |
| 520 | +
|
| 521 | + # Team-specific owned globs |
| 522 | + /app/services/bar_stuff/** @MyOrg/bar-team |
| 523 | + /frontend/javascripts/bar_stuff/** @MyOrg/bar-team |
| 524 | +
|
| 525 | + # Owner metadata key in package.json |
| 526 | + /frontend/javascripts/packages/my_other_package/**/** @MyOrg/bar-team |
| 527 | +
|
| 528 | + CODEOWNERS |
| 529 | + |
| 530 | + expect_any_instance_of(codeowners_validation).to_not receive(:`) # rubocop:disable RSpec/AnyInstance |
| 531 | + expect { CodeOwnership.validate!(autocorrect: false) }.to raise_error do |e| |
| 532 | + expect(e).to be_a CodeOwnership::InvalidCodeOwnershipConfigurationError |
| 533 | + puts e.message |
| 534 | + expect(e.message).to eq <<~EXPECTED.chomp |
| 535 | + CODEOWNERS out of date. Run `bin/codeownership validate` to update the CODEOWNERS file |
| 536 | +
|
| 537 | + CODEOWNERS should contain the following lines, but does not: |
| 538 | + - "" |
| 539 | + - "/packs/my_pack/owned_file.rb @MyOrg/bar-team" |
| 540 | + - "# Owner metadata key in package.yml" |
| 541 | + - "/packs/my_other_package/**/** @MyOrg/bar-team" |
| 542 | + - "" |
| 543 | +
|
| 544 | + See https://github.com/bigrails/code_ownership#README.md for more details |
| 545 | + EXPECTED |
| 546 | + end |
| 547 | + end |
| 548 | + end |
398 | 549 | end |
399 | 550 |
|
400 | 551 | context 'code_ownership.yml has skip_codeowners_validation set' do |
|
0 commit comments