Last active
April 10, 2019 15:51
-
-
Save zjr/c1bbccc09ddea2f478ba4bd8b882ed18 to your computer and use it in GitHub Desktop.
Shell script to automatically path moved files.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
# Establish the base comparison revision, update your branch for comparing to HEAD. | |
branch=chartreux | |
base=$(git merge-base head ${branch}) | |
# Conflicts listed line by line in format of `<old path> <new path>`, careful to note the space between. | |
conflicts="oldFilePath1.js newFilePath1.js | |
oldFilePath2.js newFilePath2.js" | |
while read -r line; do | |
files=(${line}) | |
old=${files[0]} | |
new=${files[1]} | |
git diff ${base}..${branch} ${old} > patch_file | |
patch -p1 ${new} patch_file | |
done <<< "$conflicts" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment