Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- debug_mode=1
- function debug {
- if [[ debug_mode -eq 1 ]]; then echo $1;fi;
- }
- if [[ ! -a .ciwhitelist ]]; then
- debug "Empty White List"
- exit # If .ciwhitelsit doesn't exists, just quit this Git hook
- fi
- # Load in every file that will be changed via this commit into an array
- changes=( `git diff --name-only --cached .` )
- # Load the patterns we want to skip into an array
- whitelist=( `cat .ciwhitelist` )
- if [[ ${#changes[@]} -eq 1 ]]; then
- changes[0]=$changes
- fi
- for i in "${!changes[@]}"; do
- debug changes[i]
- for file in "${whitelist[@]}"; do
- if [[ ! "${changes[i]}" =~ [$file] ]]; then
- unset changes[i]
- fi
- done
- done
- if [[ ${#changes[@]} -gt 0 ]]; then
- debug "Run ci"
- exit
- fi
- #add skip ci for commits
- if [[ debug_mode -eq 1 ]]; then
- echo "Skip CI"
- else
- echo "[skip ci]" >> $1
- fi
- dg@m
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement