react-native-macos/scripts
Pavlos Vinieratos 73844712b6 Fixing the git attrs for all the people and all the files and all future (#31128)
Summary:
We have had problems with `.gitattributes`, `.bat` and `.pbxproj` (Xcode) files for a while. The two main concerns were:
- Xcode project files not diffing correctly.
- Windows files having messed up line endings.
This PR fixes both issues, hopefully forever.

After seeing the diffs from v0.63 -> v0.64 and the changes in https://github.com/facebook/react-native/pull/29792, I, again, felt that this is going to cause problems, so I looked into both issues.

I started with `git check-attr -a Artsy.xcodeproj/project.pbxproj` after removing the `.gitattributes` file that contained `*.pbxproj -text` and there are no "guessed" attributes that would break things, and diffing and checking in worked well with the current git version. I agree this is not needed, so I left it out.

I looked into what it was doing before, and it was telling git (for the xcode project file) to "unset text", which means (according to https://git-scm.com/docs/gitattributes#_text) that it should not try to do any line ending changes when checking in that file. At some point git must have done this, and that's why it was needed, but no more, so it's safe and good to get rid of this, as it helps with nothing anymore.

Now for the bat files. We don't need any extra instructions for `gradle` and `*.sh` files as they are guessed correctly, so these are also safe to keep removed (https://github.com/facebook/react-native/pull/29792/files#diff-618cd5b83d62060ba3d027e314a21ceaf75d36067ff820db126642944145393eL5).

But we do need the `*.bat` instruction. I noticed that when working on macOS there were two problems that made things funky.
- One, is that the editor (usually vscode but not the important) would convert line endings to lf when editing a bat file.
- Two, is that git thought the files are lf line endings.

To fix the first one, I added a rule in `.editorconfig` (that's whats important, when any editor just supports editorconfig, but all my editors do). I can't believe how we missed that for sooooo long {emoji:1f605}!

To fix the second, I added the `.gitattributes` instruction **and** `renormalize`d the files (https://git-scm.com/docs/git-add#Documentation/git-add.txt---renormalize and https://docs.github.com/en/github/using-git/configuring-git-to-handle-line-endings#refreshing-a-repository-after-changing-line-endings). I think the problem all along was that even though the files had crlf, git still thought they were using lf.

After the editorconfig change and the renormalization, everything behaves correctly and as expected. Changing bat files on macOS and Windows is fine now, producing only the smallest change needed, no random line ending diffs. Also here is a screenshot of one of the files actually crlf. It's these tiny things at the end of each line {emoji:1f453}.
<img width="612" alt="Screenshot 2021-03-10 at 12 20 28" src="https://user-images.githubusercontent.com/100233/110630943-ef536280-819d-11eb-9212-dbd70f038a44.png">

I have tested this on macOS and Windows, doing changes in both bat and xcode files, and verified that diffing and checking in files works well.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[General] [Added] - Added an `.editorconfig` file to help with default line endings for Windows files.

[Internal] [Fixed] - Added a rule in `.editorconfig` and `.gitattributes` to help with default line endings for Windows files.

Pull Request resolved: https://github.com/facebook/react-native/pull/31128

Test Plan: Feel free to go on a macOS or Windows machine (or both) and, using any editor that supports editorconfig, do any change in a `.bat` file. Then look at your git diff in terminal or gui or whatever you use, and then look at the sky and smile. It's fixed. The diff is just your change. Everything is as it should {emoji:1f49c}.

Reviewed By: nadiia

Differential Revision: D27914636

Pulled By: hramos

fbshipit-source-id: fc4e53a4fa42cb13e29686669e8de1679c2242e7
2021-04-21 11:27:32 -07:00
..
circleci Add Java linting using google-java-format (#30444) 2020-12-07 03:12:35 -08:00
versiontemplates Migrate large amount of modules to flow strict and strict-local 2020-07-22 09:46:16 -07:00
.packager.env Move YGStyle to seperate file and add constructors 2018-02-20 05:55:36 -08:00
.tests.env Docker android: addressing AVD launch issue (#30279) 2020-10-31 12:48:54 -07:00
android-e2e-test.js "The Metro Server" -> Metro 2020-07-02 14:51:18 -07:00
android-setup.sh Docker android: addressing AVD launch issue (#30279) 2020-10-31 12:48:54 -07:00
bump-oss-version.js Split React Native repo into product/infra packages 2020-08-18 12:10:09 -07:00
compose-source-maps.js Tidy up license headers [2/n] 2019-10-16 10:06:34 -07:00
find-node.sh Re-use Node path resolution script 2021-04-02 13:56:52 -07:00
generate-api-docs.js Generate doc info for RN components 2019-09-19 18:36:25 -07:00
generate-specs-cli.js Remove moduleSpecName 2021-01-07 19:39:56 -08:00
generate-specs.sh Avoid encoding local path in Podfile.lock 2021-04-16 14:42:34 -07:00
ios-configure-glog.sh fix glog pod install with Xcode 12 (#30372) 2021-01-19 13:45:15 -08:00
launchPackager.bat Fixing the git attrs for all the people and all the files and all future (#31128) 2021-04-21 11:27:32 -07:00
launchPackager.command Metro Bundler -> Metro 2019-08-16 10:37:10 -07:00
lint-java.js Add Java linting using google-java-format (#30444) 2020-12-07 03:12:35 -08:00
node-binary.sh Fix: use NODE_BINARY when starting packager (#24156) 2019-04-10 07:39:23 -07:00
objc-test.sh Migrating RNTester to Packages Directory (#29567) 2020-08-19 17:57:08 -07:00
packager.sh Use CocoaPods-based RNTesterPods for iOS tests (#25416) 2019-06-28 19:18:10 -07:00
process-podspecs.sh Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
publish-npm.js remove -javadoc.jar, -sources.jar from NPM package validation (#30686) 2021-01-05 17:44:51 -08:00
react-native-xcode.sh Re-use Node path resolution script 2021-04-02 13:56:52 -07:00
react_native_pods.rb Avoid encoding local path in Podfile.lock 2021-04-16 14:42:34 -07:00
run-android-ci-instrumentation-tests.js Upgrade Prettier in Xplat to version 1.19.1 2020-04-09 11:01:58 -07:00
run-android-emulator.sh Move non-license comments out of license header 2019-10-15 20:12:12 -07:00
run-android-local-integration-tests.sh Updating the URLs to point at new domain name reactnative.dev 2020-02-24 13:09:11 -08:00
run-android-local-unit-tests.sh Updating the URLs to point at new domain name reactnative.dev 2020-02-24 13:09:11 -08:00
run-ci-e2e-tests.js Create `@react-native/polyfills` package. 2020-07-22 03:02:45 -07:00
run-ci-javascript-tests.js Add react-native-oss-e2e job to Sandcastle, running JavaScript e2e tests from open source 2019-04-15 11:07:54 -07:00
run-instrumentation-tests-via-adb-shell.sh Move non-license comments out of license header 2019-10-15 20:12:12 -07:00
set-rn-template-version.js Adjust test manual e2e script to work with new init (#24583) 2019-04-25 02:03:10 -07:00
sync-css-layout.sh Clean up instances of scripts/signedsource.py 2019-03-14 13:42:27 -07:00
test-manual-e2e.sh Migrating RNTester to Packages Directory (#29567) 2020-08-19 17:57:08 -07:00
try-n-times.js Fix linting issues (#22062) 2018-11-01 14:29:16 -07:00
validate-android-device-env.sh Update Broken Link #devcjog25 (#27025) 2019-10-28 12:11:45 -07:00
validate-android-sdk.sh Updating the URLs to point at new domain name reactnative.dev 2020-02-24 13:09:11 -08:00
validate-android-test-env.sh Updating the URLs to point at new domain name reactnative.dev 2020-02-24 13:09:11 -08:00
validate-ios-test-env.sh Update Node version to >= 12 (#30252) 2020-10-29 07:40:36 -07:00