Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. debug_mode=1
  2. function debug {
  3. if [[ debug_mode -eq 1 ]]; then echo $1;fi;
  4. }
  5.  
  6. if [[ ! -a .ciwhitelist ]]; then
  7. debug "Empty White List"
  8. exit # If .ciwhitelsit doesn't exists, just quit this Git hook
  9. fi
  10.  
  11. # Load in every file that will be changed via this commit into an array
  12. changes=( `git diff --name-only --cached .` )
  13.  
  14. # Load the patterns we want to skip into an array
  15. whitelist=( `cat .ciwhitelist` )
  16. if [[ ${#changes[@]} -eq 1 ]]; then
  17. changes[0]=$changes
  18. fi
  19.  
  20. for i in "${!changes[@]}"; do
  21. debug changes[i]
  22. for file in "${whitelist[@]}"; do
  23. if [[ ! "${changes[i]}" =~ [$file] ]]; then
  24. unset changes[i]
  25. fi
  26. done
  27. done
  28.  
  29. if [[ ${#changes[@]} -gt 0 ]]; then
  30. debug "Run ci"
  31. exit
  32. fi
  33.  
  34. #add skip ci for commits
  35. if [[ debug_mode -eq 1 ]]; then
  36. echo "Skip CI"
  37. else
  38. echo "[skip ci]" >> $1
  39. fi
  40. dg@m
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement