forked from jan-leila/nix-config
		
	feat: supported branching for commit checking
This commit is contained in:
		
							parent
							
								
									0c88746da1
								
							
						
					
					
						commit
						260e37e016
					
				
					 3 changed files with 100 additions and 9 deletions
				
			
		
							
								
								
									
										37
									
								
								.hooks/pre-merge-commit
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										37
									
								
								.hooks/pre-merge-commit
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,37 @@ | |||
| #!/usr/bin/env nix-shell | ||||
| #! nix-shell -i bash ../shell.nix | ||||
| 
 | ||||
| # Get the target branch (the branch being merged into) | ||||
| target_branch="" | ||||
| 
 | ||||
| # Check if we're in the middle of a merge | ||||
| if [ -f .git/MERGE_HEAD ]; then | ||||
|     # We're in a merge, check if the current branch is main | ||||
|     current_branch=$(git branch --show-current) | ||||
|     if [ "$current_branch" = "main" ]; then | ||||
|         target_branch="main" | ||||
|     fi | ||||
| fi | ||||
| 
 | ||||
| # If we're merging into main, run nix flake check | ||||
| if [ "$target_branch" = "main" ]; then | ||||
|     echo "Merging into main branch - running nix flake check..." | ||||
|      | ||||
|     echo "stashing all uncommitted changes" | ||||
|     git stash -q --keep-index | ||||
| 
 | ||||
|     echo "checking flakes all compile" | ||||
|     nix flake check | ||||
| 
 | ||||
|     if [ ! $? -eq 0 ]; then | ||||
|         echo "Error: nix flake check failed. Merge aborted." | ||||
|         echo "Please fix the issues and try merging again." | ||||
|         exit 1 | ||||
|     fi | ||||
|      | ||||
|     echo "nix flake check passed. Merge can proceed." | ||||
| else | ||||
|     echo "Not merging into main branch, skipping nix flake check." | ||||
| fi | ||||
| 
 | ||||
| exit 0 | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue