update_patches.sh 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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}" ]]; then
  18. echo applying patch: "${1}"
  19. if ! git apply --ignore-whitespace "${1}"; then
  20. echo failed to apply patch "${1}"
  21. git apply --reject "${1}"
  22. git apply --reject "../patches/helper/settings.patch"
  23. read -rp "Press any key when the conflict have been resolved..." -n1 -s
  24. git restore .vscode/settings.json
  25. git add .
  26. git diff --staged -U1 > "${1}"
  27. fi
  28. git add .
  29. git reset -q --hard HEAD
  30. fi
  31. }
  32. cd vscode || { echo "'vscode' dir not found"; exit 1; }
  33. git add .
  34. git reset -q --hard HEAD
  35. for FILE in ../patches/*.patch; do
  36. check_file "${FILE}"
  37. done
  38. if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
  39. for FILE in ../patches/insider/*.patch; do
  40. check_file "${FILE}"
  41. done
  42. fi
  43. for ARCH in alpine linux osx windows; do
  44. for FILE in "../patches/${ARCH}/"*.patch; do
  45. if [[ "${FILE}" != *"/arch-"* ]]; then
  46. check_file "${FILE}"
  47. fi
  48. done
  49. if [[ "${ARCH}" == "linux" ]]; then
  50. check_file "../patches/linux/arch-0-support.patch"
  51. check_file "../patches/linux/arch-0-support.patch" "../patches/linux/arch-1-ppc64le.patch"
  52. check_file "../patches/linux/arch-0-support.patch" "../patches/linux/arch-1-ppc64le.patch" "../patches/linux/arch-2-riscv64.patch"
  53. check_file "../patches/linux/arch-0-support.patch" "../patches/linux/arch-1-ppc64le.patch" "../patches/linux/arch-2-riscv64.patch" "../patches/linux/arch-3-loong64.patch"
  54. check_file "../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"
  55. fi
  56. for TARGET in client reh; do
  57. for FILE in "../patches/${ARCH}/${TARGET}/"*.patch; do
  58. check_file "${FILE}"
  59. done
  60. for FILE in "../patches/${ARCH}/${TARGET}/"*/*.patch; do
  61. check_file "${FILE}"
  62. done
  63. done
  64. done