mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 07:02:44 +00:00 
			
		
		
		
	gml-format: Exit with non-0 exit code when the file formatting changes
This let's CI detect when the changes include incorrect GML formatting. We now also print a message to make it obvious why CI failed.
This commit is contained in:
		
							parent
							
								
									9f85b4ff7b
								
							
						
					
					
						commit
						e2d797dd60
					
				
					 1 changed files with 10 additions and 5 deletions
				
			
		|  | @ -43,7 +43,7 @@ ErrorOr<bool> format_file(StringView path, bool inplace) | |||
|     } else { | ||||
|         out("{}", formatted_gml); | ||||
|     } | ||||
|     return true; | ||||
|     return formatted_gml == contents; | ||||
| } | ||||
| 
 | ||||
| ErrorOr<int> serenity_main(Main::Arguments args) | ||||
|  | @ -66,14 +66,19 @@ ErrorOr<int> serenity_main(Main::Arguments args) | |||
|         TRY(Core::System::pledge("stdio rpath", nullptr)); | ||||
| #endif | ||||
| 
 | ||||
|     unsigned exit_code = 0; | ||||
| 
 | ||||
|     if (files.is_empty()) | ||||
|         files.append("-"); | ||||
| 
 | ||||
|     auto formatting_changed = false; | ||||
|     for (auto& file : files) { | ||||
|         if (!TRY(format_file(file, inplace))) | ||||
|             exit_code = 1; | ||||
|             formatting_changed = true; | ||||
|     } | ||||
| 
 | ||||
|     return exit_code; | ||||
|     if (formatting_changed) { | ||||
|         dbgln("Some GML formatting issues were encountered."); | ||||
|         return 1; | ||||
|     } | ||||
| 
 | ||||
|     return 0; | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Idan Horowitz
						Idan Horowitz