git hooks: nekontroluj migrace flakem
This commit is contained in:
		
							parent
							
								
									51ae429040
								
							
						
					
					
						commit
						c7ebb9305b
					
				
					 2 changed files with 13 additions and 2 deletions
				
			
		|  | @ -8,7 +8,10 @@ FLAKE8="`git rev-parse --show-toplevel`/bin/flake8" | ||||||
| 
 | 
 | ||||||
| status=0 | status=0 | ||||||
| 
 | 
 | ||||||
| git diff --unified=1 --cached HEAD -- '*py' > $TMPDIFF | # select only changed python files which are not migrations | ||||||
|  | changed=`git diff --cached --name-only | grep 'py$' | grep -v 'migrations/[0-9]'` | ||||||
|  | 
 | ||||||
|  | git diff --unified=1 --cached HEAD -- $changed > $TMPDIFF | ||||||
| 
 | 
 | ||||||
| # only do the check when there are some changes to be commited | # only do the check when there are some changes to be commited | ||||||
| # otherwise flake8 would hang waiting for input | # otherwise flake8 would hang waiting for input | ||||||
|  |  | ||||||
|  | @ -27,7 +27,15 @@ TMPDIFF=`tempfile` | ||||||
| 
 | 
 | ||||||
| [ $refname != "refs/heads/master" -a $refname != "refs/heads/stable" ] && exit 0 | [ $refname != "refs/heads/master" -a $refname != "refs/heads/stable" ] && exit 0 | ||||||
| 
 | 
 | ||||||
| git diff --unified=1 $oldrev $newrev -- '*.py' >${TMPDIFF} | # select only changed python files which are not migrations | ||||||
|  | changed=`git diff --name-only $oldrev $newrev | grep 'py$' | grep -v 'migrations/[0-9]'` | ||||||
|  | if [ -z $changed ] ; then | ||||||
|  |     # Nothing to check. Note the exit is necessary -- we would not pass any | ||||||
|  |     # paths to git diff below and it would output the diff unfiltered. | ||||||
|  |     exit 0 | ||||||
|  | fi | ||||||
|  | 
 | ||||||
|  | git diff --unified=1 $oldrev $newrev -- $changed >${TMPDIFF} | ||||||
| 
 | 
 | ||||||
| # there is no working tree in bare git repository, so we recreate it for flake8 | # there is no working tree in bare git repository, so we recreate it for flake8 | ||||||
| git archive $newrev | tar -x -C ${TMPDIR} | git archive $newrev | tar -x -C ${TMPDIR} | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Matěj Kocián
						Matěj Kocián