Browse files

Suggest git apply --reject for failed upgrades

The upgrade script uses `git apply --3way`:

If you've already upgraded something that React Native upgraded, this will silently fail. For example if you have already upgraded Gradle to the version available in the new version of React Native, the 3-way patch will fail. In this case, the upgraded version is installed into `node_modules` but `package.json` is not updated. More context, discussion, and information is in #12112 (comment).

Until a more robust solution is implemented, this PR proposes to mitigate the effects of the problem by informing the user of the possible issue and instructing them of a workaround.

In an affected project, I ran `react-native-git-upgrade` after applying my patch.

As expected, I now receive the following output:


After running the suggested command, `git status` now shows me the two rejections:


And I can now [manually apply]( these changes.

[CLI] [ENHANCEMENT] [react-native-git-upgrade/cliEntry.js] - Provide instructions for upgrading React Native when 3-way merges don't apply
Closes #18636

Differential Revision: D7603073

Pulled By: hramos

fbshipit-source-id: 32d387e1ee67d8b182d248c585cd33ba94808357
  • Loading branch information...
getaaron authored and facebook-github-bot committed Apr 12, 2018
1 parent 88139eb commit 4fbd244b9a6b62e0efe1b4b5a7ec3de468f020f6
Showing with 3 additions and 1 deletion.
  1. +3 −1 react-native-git-upgrade/cliEntry.js
@@ -376,7 +376,9 @@ async function run(requestedVersion, cliArgs) {
} catch (err) {
'The upgrade process succeeded but there might be conflicts to be resolved. ' +
'See above for the list of files that have merge conflicts.');
'See above for the list of files that have merge conflicts. ' +
'If you don’t see the expected changes, try running:\n' +
`git apply --reject ${patchPath}`);
} finally {'Upgrade done');
if (cliArgs.verbose) {

0 comments on commit 4fbd244

Please sign in to comment.