| 
									
										
										
										
											2012-08-09 16:42:18 -07:00
										 |  |  | #!/bin/sh
 | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | # Our "pre-commit" hook. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # save current config | 
					
						
							|  |  |  | echo "\n\nSaving current config\n\n" | 
					
						
							|  |  |  | cp config.status tmp.status | 
					
						
							| 
									
										
										
										
											2015-01-13 16:22:21 -07:00
										 |  |  | cp wolfssl/options.h tmp.options.h  | 
					
						
							| 
									
										
										
										
											2012-08-09 16:42:18 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-13 13:38:58 -06:00
										 |  |  | # stash modified files, if any, that are not part of this commit, don't test | 
					
						
							|  |  |  | # them | 
					
						
							|  |  |  | STASHED=0 | 
					
						
							|  |  |  | if ! git diff --quiet | 
					
						
							|  |  |  | then | 
					
						
							|  |  |  |     STASHED=1 | 
					
						
							|  |  |  |     echo "\n\nStashing modified files not part of commit\n\n" | 
					
						
							|  |  |  |     git stash -q --keep-index | 
					
						
							|  |  |  | fi | 
					
						
							| 
									
										
										
										
											2012-08-09 16:42:18 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | # do the commit tests | 
					
						
							| 
									
										
										
										
											2015-01-03 23:33:14 -07:00
										 |  |  | echo "\n\nRunning commit tests...\n\n" | 
					
						
							|  |  |  | ./commit-tests.sh | 
					
						
							| 
									
										
										
										
											2012-08-09 16:42:18 -07:00
										 |  |  | RESULT=$? | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # restore modified files not part of this commit | 
					
						
							| 
									
										
										
										
											2020-11-13 13:38:58 -06:00
										 |  |  | if test $STASHED -eq 1 | 
					
						
							|  |  |  | then | 
					
						
							|  |  |  |     echo "\n\nPopping stashed modified files not part of commit\n" | 
					
						
							|  |  |  |     git stash pop -q | 
					
						
							|  |  |  | fi | 
					
						
							| 
									
										
										
										
											2012-08-09 16:42:18 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | # restore current config | 
					
						
							|  |  |  | echo "\nRestoring current config\n" | 
					
						
							|  |  |  | mv tmp.status config.status | 
					
						
							| 
									
										
										
										
											2019-12-24 12:29:33 -06:00
										 |  |  | # don't show output in case error from above | 
					
						
							| 
									
										
										
										
											2012-08-09 16:42:18 -07:00
										 |  |  | ./config.status >/dev/null 2>&1 | 
					
						
							| 
									
										
										
										
											2015-01-13 16:22:21 -07:00
										 |  |  | mv tmp.options.h wolfssl/options.h  | 
					
						
							| 
									
										
										
										
											2012-08-09 16:42:18 -07:00
										 |  |  | make clean >/dev/null 2>&1 | 
					
						
							|  |  |  | make -j 8 >/dev/null 2>&1 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ $RESULT -ne 0 ] && echo "\nOops, your commit failed\n" && exit 1 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | echo "\nCommit tests passed!\n" | 
					
						
							|  |  |  | exit 0 |