create_patches.sh 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/bin/bash
  2. TMP_BRANCH="$(date +%s)";
  3. # Ordered branches to create patches from
  4. BRANCHES=("misc" \
  5. "openexr" \
  6. "opencollada" \
  7. "openvdb" \
  8. "oiio" \
  9. "cycles" \
  10. "python3.7" \
  11. "python3.8" \
  12. "python3.9" \
  13. "python3.10" \
  14. "python3.11" \
  15. "python3.12" \
  16. "ffmpeg");
  17. PATCHES=("0000_misc.patch" \
  18. "0001_openexr3.patch" \
  19. "0002_opencollada1_6_68.patch" \
  20. "0003_openvdb.patch" \
  21. "0004_openimageio.patch" \
  22. "0005_cycles.patch" \
  23. "0006_python3_7.patch" \
  24. "0007_python3_8.patch" \
  25. "0008_python3_9.patch" \
  26. "0009_python3_10.patch" \
  27. "0010_python3_11.patch" \
  28. "0011_python3_12.patch" \
  29. "0012_ffmpeg.patch")
  30. if [[ -f ".creating_patches" ]]; then
  31. echo "Creating patches already active, maybe there was a merge conflict?";
  32. exit 1;
  33. fi
  34. # Create a new TMP branch from vanilla source
  35. git checkout master;
  36. git branch "${TMP_BRANCH}";
  37. git checkout "${TMP_BRANCH}";
  38. # Merge branches into our TMP branch and created patches while doing so
  39. for i in ${!BRANCHES[@]}; do
  40. branch="${BRANCHES[${i}]}"
  41. patch="${PATCHES[${i}]}"
  42. # Write git log for branch
  43. git checkout "${branch}"
  44. git log master.."${branch}" > "patches/${patch}"
  45. echo "" >> "patches/${patch}"
  46. git checkout "${TMP_BRANCH}"
  47. # Merge branch
  48. git merge "${branch}" --no-ff -m "Merge branch ${branch} into ${TMP_BRANCH}";
  49. # Merge conflict
  50. if [[ $? -ne 0 ]]; then
  51. conflicting=$(git diff --name-only --diff-filter=U --relative)
  52. while [ -n "${conflicting}" ]; do
  53. echo "The following files have conflict(s):"
  54. echo "-----------------------------------"
  55. echo "${conflicting}"
  56. echo "-----------------------------------"
  57. read -p "Please resolve the conflict(s), stage the resolved file(s) and press any key to continue."
  58. conflicting=$(git diff --name-only --diff-filter=U --relative)
  59. done
  60. git commit -m "Merge branch ${branch} into ${TMP_BRANCH}";
  61. fi
  62. # Create patch
  63. git diff HEAD^ HEAD >> "patches/${patch}"
  64. done
  65. # Checkout master branch so we can delete the TMP branch
  66. git checkout master
  67. # Delete TMP branch
  68. git branch -D "${TMP_BRANCH}"