question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Consider JavaScript files as binary in .gitattributes

See original GitHub issue

Is your feature request related to a problem? Please describe.

Very often in this repository, the jQuery JavaScript library is referenced in HTML files with SRI (Subresource Integrity), meaning that a hash of the file is provided as an attribute. Therefore it is crucial that JavaScript files are not modified when pushed to the repository. Git settings like core.autocrlf (defaults to true under Git tools for Windows) can therefore cause issues that are not immediately noted. The more SRI we use, the more often this problem might occur.

Describe the solution you’d like

If *.js files would be considered as binary in ´.gitattributes´, they should not be altered when being pushed to the repository.

Additional context

Suggested fix: add *.js binary in .gitattributes

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
wenzcommented, Apr 1, 2020

ah, our replies overlapped 😉 Yes, just “hardcoding” jquery.js and jquery.min.js into .gitattributes might be even better since it only affects those libraries where we are actually using SRI currently. Probably jquery*.js eol=lf is good enough (subject to verifying that it works)?

1reaction
SteveSandersonMScommented, Apr 1, 2020

I see, thanks for clarifying. So we do hard-code hashes in our sources 😃 In that case I agree it’s problematic to allow CRLF conversion for those files.

However like @javiercn points out, we wouldn’t want to set .gitattributes to treat every single .js file in the repo as binary, since that would break our normal workflows for seeing diffs for .js files that we do actually edit. Instead, I suggest there should be more targeted .gitattributes rules pointing just to the exact problematic files (or perhaps narrow this rule down to files called jquery.js anywhere in the repo).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does Git treat this text file as a binary file?
sql file), but git treats it as a binary file, even if it has only ASCII/UTF8 data on it. The reason, is that...
Read more >
Git Attributes
One cool trick for which you can use Git attributes is telling Git which files are binary (in cases it otherwise may not...
Read more >
Git - gitattributes Documentation
A gitattributes file is a simple text file that gives attributes to pathnames. ... Git decides by itself whether the file is text...
Read more >
Git file force as binary
I've added a .gitattributes file to the repo, which includes the line style.min.css binary . My understanding is this line should force Git...
Read more >
Please Add .gitattributes To Your Git Repository
gitattributes file allows you to specify the files and paths attributes that should be used by git when performing git actions, such as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found