Skip to content

Detect zz_generated.*.go as generated#7870

Open
pirothat wants to merge 4 commits intogithub-linguist:mainfrom
pirothat:detect-go-zz-generated-files
Open

Detect zz_generated.*.go as generated#7870
pirothat wants to merge 4 commits intogithub-linguist:mainfrom
pirothat:detect-go-zz-generated-files

Conversation

@pirothat
Copy link
Copy Markdown

@pirothat pirothat commented Mar 23, 2026

Description

#7784

Checklist:

  • I am adding new or changing current functionality
    • I have added or updated the tests for the new or changed functionality.

Detect generated Go files matching *_generated.*.go
Add test for generated Go files matching *_generated.*.go
Add Go sample file for *_generated.*.go detection
@pirothat pirothat requested a review from a team as a code owner March 23, 2026 13:22
@pirothat pirothat changed the title Detect go zz generated files Detect Go zz_generated.*.go as generated Mar 23, 2026
@lildude
Copy link
Copy Markdown
Member

lildude commented May 1, 2026

Please state in the PR template where you got the sample from and it's license.

@Alhadis Alhadis changed the title Detect Go zz_generated.*.go as generated Detect Go zz_generated.*.go as generated May 1, 2026
@Alhadis Alhadis changed the title Detect Go zz_generated.*.go as generated Detect zz_generated.*.go as generated May 1, 2026
Comment thread lib/linguist/generated.rb

def generated_go?
return false unless extname == '.go'
return true if !!name.match(/(^|\/)[^\/]*_generated\..+\.go$/)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a much cleaner way to write this:

Suggested change
return true if !!name.match(/(^|\/)[^\/]*_generated\..+\.go$/)
return false unless name =~ %r{(?:^|/)[^/]*_generated\..+\.go$}

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants