| 
									
										
										
										
											2020-06-12 21:50:23 -07:00
										 |  |  | #!/usr/bin/env bash
 | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | # Runs commitlint in the provided subdirectory | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | set -e | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | basedir=$1 | 
					
						
							|  |  |  | if [[ -z "$basedir" ]]; then | 
					
						
							| 
									
										
										
										
											2020-06-13 14:13:47 -07:00
										 |  |  |   basedir=. | 
					
						
							| 
									
										
										
										
											2020-06-12 21:50:23 -07:00
										 |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if [[ ! -d "$basedir" ]]; then | 
					
						
							|  |  |  |   echo "Error: not a directory: $basedir" | 
					
						
							|  |  |  |   exit 1 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if [[ ! -f "$basedir"/commitlint.config.js ]]; then | 
					
						
							|  |  |  |   echo "Error: No commitlint configuration found" | 
					
						
							|  |  |  |   exit 1 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-13 16:37:18 -05:00
										 |  |  | if [[ -z $COMMIT_RANGE ]]; then | 
					
						
							|  |  |  |   echo "Error: COMMIT_RANGE not defined" | 
					
						
							| 
									
										
										
										
											2020-06-12 21:50:23 -07:00
										 |  |  |   exit 1 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | cd "$basedir" | 
					
						
							| 
									
										
										
										
											2021-09-13 16:37:18 -05:00
										 |  |  | echo "Checking commits in COMMIT_RANGE: $COMMIT_RANGE" | 
					
						
							| 
									
										
										
										
											2020-06-12 21:50:23 -07:00
										 |  |  | while IFS= read -r line; do | 
					
						
							|  |  |  |   echo "$line" | npx commitlint | 
					
						
							| 
									
										
										
										
											2021-09-13 16:37:18 -05:00
										 |  |  | done < <(git log "$COMMIT_RANGE" --format=%s -- .) |