| 
									
										
										
										
											2025-04-29 09:41:20 +01:00
										 |  |  | { pkgs, ... }: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | pkgs.writeShellApplication { | 
					
						
							|  |  |  |   name = "dev-commit"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   runtimeInputs = with pkgs; [ | 
					
						
							|  |  |  |     coreutils | 
					
						
							|  |  |  |     git | 
					
						
							| 
									
										
										
										
											2025-07-29 18:20:33 +01:00
										 |  |  |     logger | 
					
						
							| 
									
										
										
										
											2025-04-29 09:41:20 +01:00
										 |  |  |     openssh | 
					
						
							|  |  |  |   ]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   text = ''
 | 
					
						
							|  |  |  |     IFS=':' read -ra repos <<< "$DEV_COMMIT_PATHS" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for repo in "''${repos[@]}"; do | 
					
						
							| 
									
										
										
										
											2025-07-29 18:20:33 +01:00
										 |  |  |       logger "Processing repository: $repo" | 
					
						
							| 
									
										
										
										
											2025-04-29 09:41:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-29 18:20:33 +01:00
										 |  |  |       pushd "$repo" > /dev/null 2>&1 | 
					
						
							| 
									
										
										
										
											2025-04-29 09:41:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-29 18:20:33 +01:00
										 |  |  |       if [[ -n $(git status --porcelain) ]]; then | 
					
						
							|  |  |  |         logger "Changes detected in $repo" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         git status --short | while read -r line; do | 
					
						
							|  |  |  |           logger "Changed file: $line" | 
					
						
							|  |  |  |         done | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         git add . | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if git commit -m "Automated dev commit"; then | 
					
						
							|  |  |  |           logger "Commit successful in $repo" | 
					
						
							| 
									
										
										
										
											2025-07-31 12:04:36 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |           if git push; then | 
					
						
							|  |  |  |             logger "Push successful in $repo" | 
					
						
							|  |  |  |           else | 
					
						
							|  |  |  |             logger "Push failed in $repo" | 
					
						
							|  |  |  |           fi | 
					
						
							| 
									
										
										
										
											2025-07-29 18:20:33 +01:00
										 |  |  |         else | 
					
						
							|  |  |  |           logger "No changes to commit in $repo" | 
					
						
							|  |  |  |         fi | 
					
						
							|  |  |  |       else | 
					
						
							|  |  |  |         logger "No changes in $repo" | 
					
						
							|  |  |  |       fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       popd > /dev/null 2>&1 | 
					
						
							| 
									
										
										
										
											2025-04-29 09:41:20 +01:00
										 |  |  |     done | 
					
						
							|  |  |  |   '';
 | 
					
						
							|  |  |  | } |