2
0

functions.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #!/bin/bash
  2. git_file_exists() {
  3. [ "$(git ls-tree --name-only $IO_COMMIT -- $1)" = "$1" ]
  4. }
  5. git_extract() {
  6. slashes=${1//[^\/]/}
  7. git archive $IO_COMMIT $1|tar xf - -C src/$IO_COMMIT --strip-components=${#slashes}
  8. }
  9. git_commits_ordered() {
  10. format="$1"
  11. shift
  12. if [ $# -ge 1 ]; then
  13. git log --topo-order --no-walk=sorted --date=iso-local --pretty=format:"$format" "$@"
  14. fi
  15. echo
  16. }
  17. echo_lines() {
  18. for i in "$@"; do
  19. echo $i
  20. done
  21. }
  22. get_io_commits() {
  23. for COMPILER_COMMIT in $COMPILER_COMMITS; do
  24. IO_COMMIT=$(git log -n1 --pretty=format:%H $COMPILER_COMMIT -- src/libstd/io)
  25. if ! grep -q $COMPILER_COMMIT mapping.rs; then
  26. echo "-Mapping(\"$COMPILER_COMMIT\",\"$IO_COMMIT\")" >> mapping.rs
  27. fi
  28. echo $IO_COMMIT
  29. done
  30. }
  31. get_patch_commits() {
  32. find $PATCH_DIR -type f -printf %f\\n|cut -d. -f1
  33. }
  34. prepare_version() {
  35. mkdir src/$IO_COMMIT
  36. git_extract src/libstd/io/
  37. if git_file_exists src/libcore/slice/memchr.rs; then
  38. true
  39. elif git_file_exists src/libstd/sys_common/memchr.rs; then
  40. git_extract src/libstd/sys_common/memchr.rs
  41. elif git_file_exists src/libstd/sys/common/memchr.rs; then
  42. git_extract src/libstd/sys/common/memchr.rs
  43. else
  44. git_extract src/libstd/memchr.rs
  45. fi
  46. rm -f src/$IO_COMMIT/stdio.rs src/$IO_COMMIT/lazy.rs
  47. }
  48. bold_arrow() {
  49. echo -ne '\e[1;36m==> \e[0m'
  50. }
  51. custom_bashrc() {
  52. echo '
  53. if [ -f ~/.bashrc ]; then . ~/.bashrc; fi
  54. try_patch() {
  55. patch -p1 < ../../patches/$1.patch
  56. }
  57. '
  58. }
  59. bash_diff_loop() {
  60. bash --rcfile <(custom_bashrc) <> /dev/stderr
  61. while git diff --exit-code > /dev/null; do
  62. bold_arrow; echo "$1"
  63. while true; do
  64. bold_arrow; echo -n "(T)ry again or (A)bort? "
  65. read answer <> /dev/stderr
  66. case "$answer" in
  67. [tT])
  68. break
  69. ;;
  70. [aA])
  71. bold_arrow; echo "Aborting..."
  72. exit 1
  73. ;;
  74. esac
  75. done
  76. bash <> /dev/stderr
  77. done
  78. }