Guest User

Untitled

a guest
Jun 18th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 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. exit 1
  18. fi
  19.  
  20. EXT=$(echo $LINE | awk -F'.' '{ print $NF }')
  21.  
  22. case "$EXT" in
  23. "erb")
  24. erb -x -T '-' $TMPFILE | ruby -c
  25.  
  26. if [ $? -ne 0 ]; then
  27. echo "ERB parsing error in $LINE:" >&2
  28. cat $ERRFILE >&2
  29.  
  30. exit 2
  31. fi
  32. ;;
  33. "pp")
  34. /usr/bin/puppet --color=false --parseonly $TMPFILE >$ERRFILE 2>/dev/null
  35.  
  36. if [ $? -ne 0 ]; then
  37. echo "Puppet syntax error in $LINE:" >&2
  38. cat $ERRFILE >&2
  39.  
  40. exit 2
  41. fi
  42. ;;
  43. "rb")
  44. ruby -c $TMPFILE >$ERRFILE 2>/dev/null
  45.  
  46. if [ $? -ne 0 ]; then
  47. echo "Bash syntax error in $LINE:" >&2
  48. cat $ERRFILE >&2
  49.  
  50. exit 2
  51. fi
  52. ;;
  53. "sh")
  54. bash -n $TMPFILE >$ERRFILE 2>/dev/null
  55.  
  56. if [ $? -ne 0 ]; then
  57. echo "Bash syntax error in $LINE:" >&2
  58. cat $ERRFILE >&2
  59.  
  60. exit 2
  61. fi
  62. ;;
  63. *)
  64. continue
  65. ;;
  66. esac
  67.  
  68. rm -f "$ERRFILE" "$TMPFILE"
  69. exit 0
  70. done
Add Comment
Please, Sign In to add comment