-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start generating gitattributes file for generated and vendored RBI 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.
- Loading branch information
Showing
6 changed files
with
48 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,8 @@ def execute | |
end | ||
|
||
puts | ||
ensure | ||
GitAttributes.create_generated_attribute_file(@outpath) | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# typed: strict | ||
# frozen_string_literal: true | ||
|
||
class GitAttributes | ||
class << self | ||
extend T::Sig | ||
|
||
sig { params(path: Pathname).void } | ||
def create_generated_attribute_file(path) | ||
create_gitattributes_file(path, <<~CONTENT) | ||
**/*.rbi linguist-generated=true | ||
CONTENT | ||
end | ||
|
||
sig { params(path: Pathname).void } | ||
def create_vendored_attribute_file(path) | ||
create_gitattributes_file(path, <<~CONTENT) | ||
**/*.rbi linguist-vendored=true | ||
CONTENT | ||
end | ||
|
||
private | ||
|
||
sig { params(path: Pathname, content: String).void } | ||
def create_gitattributes_file(path, content) | ||
# We don't want to start creating folders, just to write | ||
# the `.gitattributes` file. So, if the folder doesn't | ||
# exist, we just return. | ||
return unless path.exist? | ||
|
||
File.write(path.join(".gitattributes"), content) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters