bump-deps.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #!/usr/bin/env bash
  2. set -e
  3. set -u
  4. # Use privileged mode, which e.g. skips using CDPATH.
  5. set -p
  6. # Ensure that the user has a bash that supports -A
  7. if [[ "${BASH_VERSINFO[0]}" -lt 4 ]]; then
  8. echo >&2 "error: script requires bash 4+ (you have ${BASH_VERSION})."
  9. exit 1
  10. fi
  11. readonly NVIM_SOURCE_DIR="${NVIM_SOURCE_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}"
  12. readonly VIM_SOURCE_DIR_DEFAULT="${NVIM_SOURCE_DIR}/.vim-src"
  13. readonly VIM_SOURCE_DIR="${VIM_SOURCE_DIR:-${VIM_SOURCE_DIR_DEFAULT}}"
  14. BASENAME="$(basename "${0}")"
  15. readonly BASENAME
  16. usage() {
  17. echo "Bump Neovim dependencies"
  18. echo
  19. echo "Usage: ${BASENAME} [ -h | --pr | --branch=<dep> | --dep=<dependency> ]"
  20. echo
  21. echo "Options:"
  22. echo " -h show this message and exit."
  23. echo " --pr submit pr for bumping deps."
  24. echo " --branch=<dep> create a branch bump-<dep> from current branch."
  25. echo " --dep=<dependency> bump to a specific release or tag."
  26. echo
  27. echo "Dependency Options:"
  28. echo " --version=<tag> bump to a specific release or tag."
  29. echo " --commit=<hash> bump to a specific commit."
  30. echo " --HEAD bump to a current head."
  31. echo
  32. echo " <dependency> is one of:"
  33. echo " \"LuaJIT\", \"libuv\", \"Luv\", \"tree-sitter\""
  34. }
  35. # Checks if a program is in the user's PATH, and is executable.
  36. check_executable() {
  37. test -x "$(command -v "${1}")"
  38. }
  39. require_executable() {
  40. if ! check_executable "${1}"; then
  41. echo >&2 "${BASENAME}: '${1}' not found in PATH or not executable."
  42. exit 1
  43. fi
  44. }
  45. require_executable "nvim"
  46. if [ $# -eq 0 ]; then
  47. usage
  48. exit 1
  49. fi
  50. PARSED_ARGS=$(getopt -a -n "$BASENAME" -o h --long pr,branch:,dep:,version:,commit:,HEAD -- "$@")
  51. DEPENDENCY=""
  52. eval set -- "$PARSED_ARGS"
  53. while :; do
  54. case "$1" in
  55. -h)
  56. usage
  57. exit 0
  58. ;;
  59. --pr)
  60. nvim -es +"lua require('scripts.bump_deps').submit_pr()"
  61. exit 0
  62. ;;
  63. --branch)
  64. DEP=$2
  65. nvim -es +"lua require('scripts.bump_deps').create_branch('$DEP')"
  66. exit 0
  67. ;;
  68. --dep)
  69. DEPENDENCY=$2
  70. shift 2
  71. ;;
  72. --version)
  73. VERSION=$2
  74. nvim -es +"lua require('scripts.bump_deps').version('$DEPENDENCY', '$VERSION')"
  75. exit 0
  76. ;;
  77. --commit)
  78. COMMIT=$2
  79. nvim -es +"lua require('scripts.bump_deps').commit('$DEPENDENCY', '$COMMIT')"
  80. exit 0
  81. ;;
  82. --HEAD)
  83. nvim -es +"lua require('scripts.bump_deps').head('$DEPENDENCY')"
  84. exit 0
  85. ;;
  86. *)
  87. break
  88. ;;
  89. esac
  90. done
  91. usage
  92. exit 1
  93. # vim: et sw=2