Skip to content

Start generating .gitattributes file for generated and vendored RBI files#1604

Merged
paracycle merged 2 commits intomainfrom
uk-add-gitattributes
Sep 8, 2023
Merged

Start generating .gitattributes file for generated and vendored RBI files#1604
paracycle merged 2 commits intomainfrom
uk-add-gitattributes

Conversation

@paracycle
Copy link
Copy Markdown
Member

Motivation

Fixes https://github.com/Shopify/ruby-dev-exp-issues/issues/651

The linguist gem added support for detecting generated and vendored RBI files in github-linguist/linguist#6143, but it parses the RBI file header comments to understand that, which is quite brittle.

Tapioca can do a better job of this, since it already knows that dsl and gem commands will create "generated" RBI files in the output directory and the annotations command will create "vendored" RBI files. So, Tapioca should be generating the appropriate .gitattributes files in the relevant output directories to signal that the RBI files contained are generated/vendored.

Implementation

  1. Added a GitAttributes helper module that knows how to create .gitattributes files that state the **/*.rbi files in the folder are either generated or vendored RBI files.
  2. Uses the helper module in DslGenerate, GemGenerate, GemSync and Annotations commands to create appropriate .gitattributes files in the output folder.

Tests

Added extra test cases for checking generated .gitattributes files.

This commit adds a `.gitattributes` file to the output folder that marks all RBI files as `generated` for `dsl` and `gem` RBI generation commands. It also add a `.gitattributes` file to the output folder that marks all RBI files as `vendored` for `annotations` command.
@paracycle paracycle requested a review from a team as a code owner August 14, 2023 21:24
@paracycle paracycle force-pushed the uk-add-gitattributes branch from 4fc0dba to 6f2f432 Compare August 14, 2023 21:51
Comment thread lib/tapioca/commands/dsl_generate.rb
Comment thread lib/tapioca/helpers/git_attributes.rb
@paracycle paracycle merged commit 4201c89 into main Sep 8, 2023
@paracycle paracycle deleted the uk-add-gitattributes branch September 8, 2023 17:31
@shopify-shipit shopify-shipit Bot temporarily deployed to production September 13, 2023 22:55 Inactive
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