update_patches.sh 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. if [[ -f "${1}" ]]; then
  14. echo applying patch: "${1}"
  15. if ! git apply --ignore-whitespace "${1}"; then
  16. echo failed to apply patch "${1}"
  17. git apply --reject "${1}"
  18. git apply --reject "../patches/helper/settings.patch"
  19. read -rp "Press any key when the conflict have been resolved..." -n1 -s
  20. git restore .vscode/settings.json
  21. git add .
  22. git diff --staged -U1 > "${1}"
  23. fi
  24. git add .
  25. git reset -q --hard HEAD
  26. fi
  27. }
  28. cd vscode || { echo "'vscode' dir not found"; exit 1; }
  29. git add .
  30. git reset -q --hard HEAD
  31. for FILE in ../patches/*.patch; do
  32. check_file "${FILE}"
  33. done
  34. if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
  35. for FILE in ../patches/insider/*.patch; do
  36. check_file "${FILE}"
  37. done
  38. fi
  39. for FILE in ../patches/linux/*/*.patch; do
  40. check_file "${FILE}"
  41. done