add .pre-commit
This commit is contained in:
		
							parent
							
								
									971c649209
								
							
						
					
					
						commit
						5084aa54b1
					
				
					 1 changed files with 13 additions and 0 deletions
				
			
		
							
								
								
									
										13
									
								
								.pre-commit
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										13
									
								
								.pre-commit
									
										
									
									
									
										Executable file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,13 @@
 | 
			
		|||
#!/bin/bash
 | 
			
		||||
set -e
 | 
			
		||||
 | 
			
		||||
function checkFile() {
 | 
			
		||||
	[[ "$1" =~ \.zone$ ]] || return 0
 | 
			
		||||
	old="$(git show HEAD:"$1"|grep -Po '\d+(?=\s+; serial)')"
 | 
			
		||||
	new="$(git show     :"$1"|grep -Po '\d+(?=\s+; serial)')"
 | 
			
		||||
	[[ "$old" -lt "$new" ]] && return 0 || { echo "serial bump check failed for $1"; return 1; }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ret=0
 | 
			
		||||
while read file; do checkFile "$file" || ret=1; done <<< "$(git diff --name-only --cached)"
 | 
			
		||||
exit $ret
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue