0

When running react-native-git-upgrade from react-native 0.56 to 0.57.3 I get through most steps but fail on Generate the patch between the 2 versions

git-upgrade info Check for updates 
git-upgrade info Using yarn 1.9.4 
git-upgrade info Read package.json files 
git-upgrade info Check declared version 
git-upgrade info Check matching versions 
git-upgrade info Check React peer dependency 
git-upgrade info Check that Git is installed 
git-upgrade info Get information from NPM registry 
git-upgrade info Upgrading to React Native 0.57.3, React 16.6.0-alpha.8af6728 
git-upgrade info Setup temporary working directory 
git-upgrade info Configure Git environment 
git-upgrade info Init Git repository 
git-upgrade info Add all files to commit 
warning: CRLF will be replaced by LF in node_modules/chain-function/.gitattributes.
The file will have its original line endings in your working directory.
warning: CRLF will be replaced by LF in node_modules/chain-function/.npmignore.
The file will have its original line endings in your working directory.
warning: CRLF will be replaced by LF in node_modules/chain-function/index.js.
The file will have its original line endings in your working directory.
warning: CRLF will be replaced by LF in node_modules/chain-function/test.js.
The file will have its original line endings in your working directory.
git-upgrade info Commit current project sources 
git-upgrade info Create a tag before updating sources 
git-upgrade info Generate old version template 
git-upgrade info Add updated files to commit 
git-upgrade info Commit old version template 
git-upgrade info Install the new version 
warning "react-native > metro > babel-preset-fbjs > @babel/plugin-check-constants@7.0.0-beta.38" has incorrect peer dependency "@babel/core@7.0.0-beta.38".
git-upgrade info Generate new version template 
git-upgrade info Add updated files to commit 
git-upgrade info Commit new version template 
git-upgrade info Generate the patch between the 2 versions 
git-upgrade ERR! An error occurred during upgrade: 
git-upgrade ERR! Error: Command 'git diff --binary --no-color HEAD~1 HEAD' exited with code null:
stderr: undefined

The specific git command that is failing is comparing two files in node_modules/`

diff --git a/node_modules/@babel/plugin-syntax-object-rest-spread/node_modules/lodash/_getSymbolsIn.js b/node_modules/@babel/plugin-syntax-object-rest-spread/node_modules/lodash/_getSymbolsIn.js
deleted file mode 100644
index cec0855..0000000
--- a/node_modulesgit-upgrade ERR! An error occurred during upgrade: 
git-upgrade ERR! Error: Command 'git diff --binary --no-color HEAD~1 HEAD' exited with code null:
stderr: undefined

EDIT:

after changing .gitignore to just ignore Pods and node_modules I get

git-upgrade info Save the patch in temp directory 
git-upgrade info Reset the 2 temporary commits 
HEAD is now at b09d589 Project snapshot
git-upgrade info Apply the patch 
error: .flowconfig: does not exist in index
error: patch failed: android/app/build.gradle:137
Falling back to three-way merge...
Applied patch to 'android/app/build.gradle' with conflicts.
error: patch failed: android/build.gradle:1
Falling back to three-way merge...
Applied patch to 'android/build.gradle' with conflicts.
error: patch failed: android/gradle/wrapper/gradle-wrapper.properties:2
Falling back to three-way merge...
Applied patch to 'android/gradle/wrapper/gradle-wrapper.properties' with conflicts.
error: patch failed: ios/Neuron.xcodeproj/project.pbxproj:13
Falling back to three-way merge...
Applied patch to 'ios/Neuron.xcodeproj/project.pbxproj' with conflicts.
error: ios/Neuron.xcodeproj/xcshareddata/xcschemes/Neuron-tvOS.xcscheme: does not exist in index
error: patch failed: ios/Neuron/Info.plist:9
Falling back to three-way merge...
Applied patch to 'ios/Neuron/Info.plist' with conflicts.
git-upgrade WARN The upgrade process succeeded but there might be conflicts to be resolved. See above for the list of files that have merge conflicts. 
git-upgrade info Upgrade done 
git-upgrade info Temporary working directory: /var/folders/dl/t15md38s6b1d9sfsnbk7my280000gn/T/react-native-git-upgrade 

There are no changes in my git directory but there is a patch at the Temp working directory

ehacinom
  • 8,070
  • 7
  • 43
  • 65

1 Answers1

0

Based off this link which suggested that the git command was failing due to .gitignore: https://github.com/facebook/react-native/issues/11402

I wiped out my .gitignore except for Pods and node_modules and it mostly worked.

When I got errors like does not exist in index or patch failed, but it also output git-upgrade info Upgrade done, and git status did not return any changes, I went to the patch at the Temporary working directory and saw there was a patch file. Discussion here: https://github.com/facebook/react-native/issues/12112#issuecomment-284491701

In my repo I applied it as per the discussion above and plan to fix the conflicts.

git apply $TMPDIR/react-native-git-upgrade/<patch file name> --reject
ehacinom
  • 8,070
  • 7
  • 43
  • 65