ncuillery / rn-diff

Easier React Native upgrades by clearly expose changes from a version to another. :rocket:

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rn-diff is not working with the instructions in Usage.

AugustoAleGon opened this issue · comments

Hello :)

I am trying to upgrade a new RN project 0.53.3 to the latest version 0.56.
I follow this steps:

curl https://github.com/ncuillery/rn-diff/compare/rn-0.53.3...rn-0.56.0.diff > upgrade-rn.patch

Then I open my file upgrade-rn.patch and substitute all the RnDiffApp for myCoolApp.

After I used this:

git remote add rn-diff https://github.com/ncuillery/rn-diff.git
git fetch rn-diff
git apply upgrade-rn.patch --exclude=package.json -p 2 --3way

I got the following error message:

error: patch failed: android/app/build.gradle:94
Falling back to three-way merge...
Applied patch to 'android/app/build.gradle' with conflicts.
error: patch failed: android/app/src/main/AndroidManifest.xml:1
Falling back to three-way merge...
Applied patch to 'android/app/src/main/AndroidManifest.xml' with conflicts.
error: cannot apply binary patch to 'android/app/src/main/res/mipmap-hdpi/ic_launcher.png' without full index line
Falling back to three-way merge...
error: cannot apply binary patch to 'android/app/src/main/res/mipmap-hdpi/ic_launcher.png' without full index line
error: android/app/src/main/res/mipmap-hdpi/ic_launcher.png: patch does not apply
error: cannot apply binary patch to 'android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png' without full index line
Falling back to three-way merge...
error: cannot apply binary patch to 'android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png' without full index line
error: android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: patch does not apply
error: cannot apply binary patch to 'android/app/src/main/res/mipmap-mdpi/ic_launcher.png' without full index line
Falling back to three-way merge...
error: cannot apply binary patch to 'android/app/src/main/res/mipmap-mdpi/ic_launcher.png' without full index line
error: android/app/src/main/res/mipmap-mdpi/ic_launcher.png: patch does not apply
error: cannot apply binary patch to 'android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png' without full index line
Falling back to three-way merge...
error: cannot apply binary patch to 'android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png' without full index line
error: android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: patch does not apply
error: cannot apply binary patch to 'android/app/src/main/res/mipmap-xhdpi/ic_launcher.png' without full index line
Falling back to three-way merge...
error: cannot apply binary patch to 'android/app/src/main/res/mipmap-xhdpi/ic_launcher.png' without full index line
error: android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: patch does not apply
error: cannot apply binary patch to 'android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png' without full index line
Falling back to three-way merge...
error: cannot apply binary patch to 'android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png' without full index line
error: android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: patch does not apply
error: cannot apply binary patch to 'android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png' without full index line
Falling back to three-way merge...
error: cannot apply binary patch to 'android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png' without full index line
error: android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: patch does not apply
error: cannot apply binary patch to 'android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png' without full index line
Falling back to three-way merge...
error: cannot apply binary patch to 'android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png' without full index line
error: android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: patch does not apply
error: cannot apply binary patch to 'android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png' without full index line
Falling back to three-way merge...
error: cannot apply binary patch to 'android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png' without full index line
error: android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: patch does not apply
error: cannot apply binary patch to 'android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png' without full index line
Falling back to three-way merge...
error: cannot apply binary patch to 'android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png' without full index line
error: android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: patch does not apply
error: ios/.xcodeproj/project.pbxproj: does not exist in index
error: ios/AppDelegate.h: does not exist in index
error: ios/AppDelegate.m: does not exist in index
error: ios/main.m: does not exist in index
error: ios/Tests/olderAppTests.m: does not exist in index

Experiencing the same with 0.55.3 to 0.56.0. From what I have read apply is used for text files, not binary. The patch needs to be generated using --binary or something in that line.

Will try updating to 0.55.4 and then 0.56.0.

Ohh got it. So First need to be 0.55.4 and then 0.56.0? What about manual upgrade? I have tried that too and I got error messages after upgrading. Any ideas?

In the end what I ended up doing was manually grabbing the images from the 0.56.0 branch, and pasting them where they need to be. I then removed the lines in the patch file that tried to compare the images as it wasn't necessary anymore.

After that I applied the patch (using the 3 way merge command given in the usage.md file) and updated my package.json file, did npm install, pod install, etc.

I am gonna try it today. Because what I don't see clear probably is the changes that I had to do in the patch files. What images do you refer?

Look at the error messages:

cannot apply binary patch to 'android/app/src/main/res/mipmap-hdpi/ic_launcher.png' without full index line

All of them have a link to where the image is located. You will find the images at that location in the branch and your own project.

In the patch file you will see similar links, they look like this:

diff --git a/RnDiffApp/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/RnDiffApp/android/app/src/main/res/mipmap-hdpi/ic_launcher.png

index cde69bcc..a2f59082 100644

Binary files a/RnDiffApp/android/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/RnDiffApp/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ

Also just to let you know, I upgraded to 0.55.4 first, but the difference between 0.55.3 and 0.55.4 seemed to be only the package.json version number based in the diff file.

Awesome. Taking notes about that. Let me try it and let you know.

I also copied the files manually and then added another exclude to the git apply command: --exclude=android/app/src/main/res/**

[edited: to clarify based on @pvinis comment below - thanks Pavlos!] There is a fork https://github.com/pvinis/rn-diff-purge which has now moved on to a different style of doing them - highly recommended to go over there at this point...

The instructions here were written by @ncuillery, not me. I do however have my own fork with a way to generate diffs that I think is better.

@AugustoAleGon I would suggest looking at the diff (here or my repo, doesn't matter, whichever you prefer), but don't try to apply a patch. Just do the changes manually.
Take rn-0.53.3...rn-0.56.0#diff-47688e69ba4c83d925cb62d0b3fb3528 and go file by file. Create a new project with the same name in a new folder. For images, just replace yours with the ones from the new project. Config files, just edit them. For Xcode project files etc, do the changes and look at the diff you generate and try to copy the "form" of what the version diff has.

Otherwise, try to do the patch way, but version by version, and not all at once. That way at least you can figure out what might be wrong, more easily.