Guest User

Untitled

a guest
Jun 18th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. export ERRFILE=$(mktemp)
  4. export PATH="/usr/bin:/bin"
  5. export REPOS="$1"
  6. export TMPFILE=$(mktemp)
  7. export TXN="$2"
  8.  
  9. svnlook changed -t "$TXN" "$REPOS" \
  10. | awk '{print $2}' \
  11. | \
  12. while read LINE; do
  13. svnlook cat -t "$TXN" "$REPOS" "$LINE" > "$TMPFILE"
  14.  
  15. if [ $? -ne 0 ]; then
  16. echo "Warning: Failed to checkout $LINE" >&2
  17. fi
  18.  
  19. EXT=$(echo $LINE | awk -F'.' '{ print $NF }')
  20.  
  21. case "$EXT" in
  22. "erb")
  23. erb -x -T '-' $TMPFILE | ruby -c
  24.  
  25. if [ $? -ne 0 ]; then
  26. echo "ERB parsing error in $LINE:" >&2
  27. cat $ERRFILE >&2
  28.  
  29. exit 2
  30. fi
  31. ;;
  32. "pp")
  33. /usr/bin/puppet --color=false --parseonly $TMPFILE >$ERRFILE 2>/dev/null
  34.  
  35. if [ $? -ne 0 ]; then
  36. echo "Puppet syntax error in $LINE:" >&2
  37. cat $ERRFILE >&2
  38.  
  39. exit 2
  40. fi
  41. ;;
  42. "rb")
  43. ruby -c $TMPFILE >$ERRFILE 2>/dev/null
  44.  
  45. if [ $? -ne 0 ]; then
  46. echo "Ruby syntax error in $LINE:" >&2
  47. cat $ERRFILE >&2
  48.  
  49. exit 2
  50. fi
  51. ;;
  52. "sh")
  53. bash -n $TMPFILE >$ERRFILE 2>/dev/null
  54.  
  55. if [ $? -ne 0 ]; then
  56. echo "Bash syntax error in $LINE:" >&2
  57. cat $ERRFILE >&2
  58.  
  59. exit 2
  60. fi
  61. ;;
  62. *)
  63. continue
  64. ;;
  65. esac
  66.  
  67. rm -f "$ERRFILE" "$TMPFILE"
  68. exit 0
  69. done
Add Comment
Please, Sign In to add comment