@@ -577,6 +577,58 @@ module CodeOwnership
577
577
end
578
578
end
579
579
end
580
+
581
+ context 'in an application with a CODEOWNERS file that has a reference to a file that has had an annotation removed' do
582
+ before do
583
+ write_configuration
584
+
585
+ write_file ( 'packs/my_pack/had_annotation_file.rb' , <<~CONTENTS )
586
+ CONTENTS
587
+
588
+ write_file ( 'config/teams/bar.yml' , <<~CONTENTS )
589
+ name: Bar
590
+ github:
591
+ team: '@MyOrg/bar-team'
592
+ CONTENTS
593
+ end
594
+
595
+ it 'prints out the diff' do
596
+ FileUtils . mkdir ( '.github' )
597
+ codeowners_path . write <<~CODEOWNERS
598
+ # STOP! - DO NOT EDIT THIS FILE MANUALLY
599
+ # This file was automatically generated by "bin/codeownership validate".
600
+ #
601
+ # CODEOWNERS is used for GitHub to suggest code/file owners to various GitHub
602
+ # teams. This is useful when developers create Pull Requests since the
603
+ # code/file owner is notified. Reference GitHub docs for more details:
604
+ # https://help.github.com/en/articles/about-code-owners
605
+
606
+ # Annotations at the top of file
607
+ /packs/my_pack/had_annotation_file.rb @MyOrg/bar-team
608
+
609
+ # Team YML ownership
610
+ /config/teams/bar.yml @MyOrg/bar-team
611
+ CODEOWNERS
612
+
613
+ expect_any_instance_of ( codeowners_validation ) . to_not receive ( :` ) # rubocop:disable RSpec/AnyInstance
614
+ expect { CodeOwnership . validate! ( autocorrect : false ) } . to raise_error do |e |
615
+ expect ( e ) . to be_a CodeOwnership ::InvalidCodeOwnershipConfigurationError
616
+ expect ( e . message ) . to eq <<~EXPECTED . chomp
617
+ Some files are missing ownership:
618
+
619
+ - packs/my_pack/had_annotation_file.rb
620
+
621
+ CODEOWNERS out of date. Run `bin/codeownership validate` to update the CODEOWNERS file
622
+
623
+ CODEOWNERS should not contain the following lines, but it does:
624
+ - "# Annotations at the top of file"
625
+ - "/packs/my_pack/had_annotation_file.rb @MyOrg/bar-team"
626
+
627
+ See https://github.com/rubyatscale/code_ownership#README.md for more details
628
+ EXPECTED
629
+ end
630
+ end
631
+ end
580
632
end
581
633
582
634
context 'code_ownership.yml has skip_codeowners_validation set' do
0 commit comments