From fc553ed8e6aa6c505a9bb42fa16e9dcd8418aeae Mon Sep 17 00:00:00 2001 From: Frieder Bluemle Date: Thu, 9 Sep 2021 22:43:15 -0700 Subject: [PATCH] Revert removal of CRLF from Windows bat files (#31398) Summary: This reverts https://github.com/facebook/react-native/issues/31128 - For the reasons stated in the thread. Files should have the correct endings in the repo (i.e. Windows .bat CRLF). There is no reason to perform additional conversion with attributes and/or an editorconfig. It was originally fixed in https://github.com/facebook/react-native/issues/29792 in August 2020. :warning: **EDIT 2021-08-31** Commits 85249cafe88 and 13107fa3d0b accidentally converted the gradlew.bat files to LF again, resulting in modified files to appear in the working directory: ``` $ git status -s M gradlew.bat M packages/react-native-codegen/android/gradlew.bat M template/android/gradlew.bat ``` The reasons why this is happening are explained in detail in the two PRs linked above. I've added an additional (new) commit to the PR head branch to fix the line endings in all three `gradlew.bat` files of the repo and rebased it. It should be ready for merge. CC cortinico EDIT 2021-09-02 The additional commit was removed again, but the original one remains. To test the scenario locally run the following commands on a clean `main` branch (currently 455433f481bf5f743a3330a9a46edda5fc69da69): ``` $ rm gradlew.bat $ git status -s D gradlew.bat # Git shows the file as (D)eleted, as expected $ git checkout gradlew.bat # This should restore the file $ git status -s M gradlew.bat # The file still shows up, now as (M)odified with all line endings changed ``` The modified file will remain in the working directory until they are committed, or a different branch is _force_ checked out. `gradlew.bat` files are generated automatically by Gradle (with the correct line endings in the first place). There is no need to special case them and perform line ending conversion using Git and/or editorconfig. ## Changelog [General] [Fixed] - Line endings in Windows files, Git/EditorConfig related conversions Pull Request resolved: https://github.com/facebook/react-native/pull/31398 Test Plan: Verify files are stored correctly in the repository (e.g. using the `file` command). Reviewed By: yungsters Differential Revision: D30839864 Pulled By: cortinico fbshipit-source-id: dfc53e8c5d9276d2f9bfd4d4a4e6b44c3143a164 --- .editorconfig | 4 ---- .gitattributes | 3 --- scripts/launchPackager.bat | 24 ++++++++++++------------ template/_editorconfig | 3 --- template/_gitattributes | 3 --- 5 files changed, 12 insertions(+), 25 deletions(-) delete mode 100644 .gitattributes delete mode 100644 template/_editorconfig delete mode 100644 template/_gitattributes diff --git a/.editorconfig b/.editorconfig index 355a800148a2d9..eeda81f4e0cb82 100644 --- a/.editorconfig +++ b/.editorconfig @@ -18,7 +18,3 @@ indent_size = 4 [BUCK] indent_size = 4 - -# Windows files -[*.bat] -end_of_line = crlf diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 45a3dcb2a20316..00000000000000 --- a/.gitattributes +++ /dev/null @@ -1,3 +0,0 @@ -# Windows files should use crlf line endings -# https://help.github.com/articles/dealing-with-line-endings/ -*.bat text eol=crlf diff --git a/scripts/launchPackager.bat b/scripts/launchPackager.bat index ce71959a16d046..aed322d7c530ce 100644 --- a/scripts/launchPackager.bat +++ b/scripts/launchPackager.bat @@ -1,12 +1,12 @@ -:: Copyright (c) Facebook, Inc. and its affiliates. -:: -:: This source code is licensed under the MIT license found in the -:: LICENSE file in the root directory of this source tree. - -@echo off -title Metro -call .packager.bat -cd ../../../ -node "%~dp0..\cli.js" start -pause -exit +:: Copyright (c) Facebook, Inc. and its affiliates. +:: +:: This source code is licensed under the MIT license found in the +:: LICENSE file in the root directory of this source tree. + +@echo off +title Metro +call .packager.bat +cd ../../../ +node "%~dp0..\cli.js" start +pause +exit diff --git a/template/_editorconfig b/template/_editorconfig deleted file mode 100644 index 7c286132fe9a98..00000000000000 --- a/template/_editorconfig +++ /dev/null @@ -1,3 +0,0 @@ -# Windows files -[*.bat] -end_of_line = crlf diff --git a/template/_gitattributes b/template/_gitattributes deleted file mode 100644 index 45a3dcb2a20316..00000000000000 --- a/template/_gitattributes +++ /dev/null @@ -1,3 +0,0 @@ -# Windows files should use crlf line endings -# https://help.github.com/articles/dealing-with-line-endings/ -*.bat text eol=crlf