update_patches.sh 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/usr/bin/env bash
  2. export VSCODE_QUALITY="stable"
  3. while getopts ":i" opt; do
  4. case "$opt" in
  5. i)
  6. export VSCODE_QUALITY="insider"
  7. ;;
  8. *)
  9. ;;
  10. esac
  11. done
  12. check_file() {
  13. while [ $# -gt 1 ]; do
  14. git apply --reject "${1}"
  15. shift
  16. done
  17. if [[ -f "${1}.bak" ]]; then
  18. mv -f $1{.bak,}
  19. fi
  20. if [[ -f "${1}" ]]; then
  21. echo applying patch: "${1}"
  22. if ! git apply --ignore-whitespace "${1}"; then
  23. echo failed to apply patch "${1}"
  24. git apply --reject "${1}"
  25. git apply --reject "../patches/helper/settings.patch"
  26. read -rp "Press any key when the conflict have been resolved..." -n1 -s
  27. git restore .vscode/settings.json
  28. git add .
  29. git diff --staged -U1 > "${1}"
  30. fi
  31. git add .
  32. git reset -q --hard HEAD
  33. fi
  34. }
  35. cd vscode || { echo "'vscode' dir not found"; exit 1; }
  36. git add .
  37. git reset -q --hard HEAD
  38. for FILE in ../patches/*.patch; do
  39. check_file "${FILE}"
  40. done
  41. if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
  42. for FILE in ../patches/insider/*.patch; do
  43. check_file "${FILE}"
  44. done
  45. fi
  46. for ARCH in alpine linux osx windows; do
  47. for FILE in "../patches/${ARCH}/"*.patch; do
  48. if [[ "${ARCH}" == "linux" && "${FILE}" == *"/arch-"* ]] || [[ "${ARCH}" == "windows" && "${FILE}" == *"/cli"* ]]; then
  49. echo "skip ${FILE}"
  50. else
  51. check_file "${FILE}"
  52. fi
  53. done
  54. if [[ "${ARCH}" == "linux" ]]; then
  55. check_file "../patches/cli.patch" "../patches/linux/arch-0-support.patch"
  56. check_file "../patches/cli.patch" "../patches/linux/arch-0-support.patch" "../patches/linux/arch-1-ppc64le.patch"
  57. check_file "../patches/cli.patch" "../patches/linux/arch-0-support.patch" "../patches/linux/arch-1-ppc64le.patch" "../patches/linux/arch-2-riscv64.patch"
  58. check_file "../patches/cli.patch" "../patches/linux/arch-0-support.patch" "../patches/linux/arch-1-ppc64le.patch" "../patches/linux/arch-2-riscv64.patch" "../patches/linux/arch-3-loong64.patch"
  59. check_file "../patches/cli.patch" "../patches/linux/arch-0-support.patch" "../patches/linux/arch-1-ppc64le.patch" "../patches/linux/arch-2-riscv64.patch" "../patches/linux/arch-3-loong64.patch" "../patches/linux/arch-4-s390x.patch"
  60. elif [[ "${ARCH}" == "windows" ]]; then
  61. check_file "../patches/cli.patch" "../patches/windows/cli.patch"
  62. fi
  63. for TARGET in client reh; do
  64. for FILE in "../patches/${ARCH}/${TARGET}/"*.patch; do
  65. check_file "${FILE}"
  66. done
  67. for FILE in "../patches/${ARCH}/${TARGET}/"*/*.patch; do
  68. check_file "${FILE}"
  69. done
  70. done
  71. done