Skip to content

@team annotation is ignored when a shebang precedes it #190

Backlog

Description

@olbrich

What happened?

Version: code_ownership 2.2.1 (the version I tested).

Summary
A file annotation is only read from line 1. A script that starts with a shebang can't carry a header there, because the shebang must stay on line 1. A header on line 2 is silently ignored. for_file returns Unowned, and validate raises no warning.

Steps to reproduce

Reproduction

config/code_ownership.yml:

owned_globs:
  - scripts/**/*.rb
unowned_globs: []
js_package_paths: []

config/teams/foo.yml:

name: Foo
github:
  team: "@org/foo"
owned_globs: []

scripts/plain.rb:

# @team Foo
puts 1

scripts/shebang_second.rb:

#!/usr/bin/env ruby
# @team Foo
puts 1

Stage the files, then look up each one:

git add -A
bin/codeownership for_file scripts/plain.rb
bin/codeownership for_file scripts/shebang_second.rb

Output:

Team: Foo
Team: Unowned

Expected behavior

Expected: shebang_second.rb belongs to Foo, or validate reports that the header was not read.

Actual: shebang_second.rb is Unowned. The header looks authoritative but does nothing.

Error output

None, it `codeownership validate` passes, but probably should not.

Version

2.2.1

Does this happen on the latest release?

Yes

Environment

ruby 4.0.10 (2026-11-19 revision a704b7cd95) +PRISM [arm64-darwin25]

Other relevant versions

No response

Relevant configuration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions