.gitattributes with typical Rails custom hunk-headers
Used 32 times
V
Viktor Schmidt
Usage
This file defines metadata for specific paths in a git repository. This metadata can be used by git and other tools to enhance their behavior. See the gitattributes documentation and linguist for more information.
Run this command in your Rails app directory in the terminal:
rails app:template LOCATION="https://railsbytes.com/script/zamsP4"
Template Source
Review the code before running this template on your machine.
def print_green(heredoc)
puts set_color heredoc, :green
end
def do_commit
git :init
git add: "."
Bundler.with_unbundled_env { git commit: " -m 'Add .gitattributes' " }
end
say "\nAdding .gitattributes..."
create_file ".gitattributes", "\n" unless File.exist? ".gitattributes"
append_file ".gitattributes" do
<<~EOF
# line endings
* text=auto eol=lf
*.{cmd,[cC][mM][dD]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf
*.json text eol=lf
*.yaml text eol=lf
*.yml text eol=lf
*.js text eol=lf
*.jsx text eol=lf
*.ts text eol=lf
*.tsx text eol=lf
package.json text eol=lf
package-lock.json text eol=lf
yarn.lock text eol=lf
*.sh text eol=lf
# Excludes documentation files from your project's language stats.
doc/* linguist-documentation
# Set standard handling for shell script files
*.sh linguist-language=Shell
*.html diff=html
*.css diff=css
*.scss diff=css
*.md diff=markdown
*.rb diff=ruby
*.rake diff=ruby
*.gemspec diff=ruby
*.json diff=json
*.yaml diff=yaml
*.yml diff=yaml
*.js diff=javascript
*.jsx diff=javascript
*.ts diff=typescript
*.tsx diff=typescript
package.json diff=json
package-lock.json diff=json
yarn.lock diff=plaintext
*.sh diff=sh
# Make your credentials diff readable
config/credentials/*.yml.enc diff=rails_credentials
config/credentials.yml.enc diff=rails_credentials
# Global fallback for text files
*.txt text
EOF
end
do_commit
print_green "\nAdded .gitattributes successfully!"