feat(parser/diff): hint truncated
This commit is contained in:
		
							parent
							
								
									f99ad5eae4
								
							
						
					
					
						commit
						e644b180a9
					
				|  | @ -71,11 +71,14 @@ func (*Diff) Run(results []stage.ExecutorResult, confAny any) ( | ||||||
| 						// Convert answer to string and split by lines
 | 						// Convert answer to string and split by lines
 | ||||||
| 						answerStr := string(answer) | 						answerStr := string(answer) | ||||||
| 						resultStr := result.Files[output.FileName] | 						resultStr := result.Files[output.FileName] | ||||||
|  | 						truncated := false | ||||||
| 						if len(answerStr) > output.MaxDiffLength { | 						if len(answerStr) > output.MaxDiffLength { | ||||||
| 							answerStr = answerStr[:output.MaxDiffLength] | 							answerStr = answerStr[:output.MaxDiffLength] | ||||||
|  | 							truncated = true | ||||||
| 						} | 						} | ||||||
| 						if len(resultStr) > output.MaxDiffLength { | 						if len(resultStr) > output.MaxDiffLength { | ||||||
| 							resultStr = resultStr[:output.MaxDiffLength] | 							resultStr = resultStr[:output.MaxDiffLength] | ||||||
|  | 							truncated = true | ||||||
| 						} | 						} | ||||||
| 						answerLines := strings.Split(answerStr, "\n") | 						answerLines := strings.Split(answerStr, "\n") | ||||||
| 						resultLines := strings.Split(resultStr, "\n") | 						resultLines := strings.Split(resultStr, "\n") | ||||||
|  | @ -89,6 +92,9 @@ func (*Diff) Run(results []stage.ExecutorResult, confAny any) ( | ||||||
| 							diffOps, | 							diffOps, | ||||||
| 						) | 						) | ||||||
| 						diffOutput = strings.TrimSuffix(diffOutput, "\n  ") | 						diffOutput = strings.TrimSuffix(diffOutput, "\n  ") | ||||||
|  | 						if truncated { | ||||||
|  | 							diffOutput += "\n\n(truncated)" | ||||||
|  | 						} | ||||||
| 						comment += fmt.Sprintf( | 						comment += fmt.Sprintf( | ||||||
| 							"```diff\n%s\n```\n", | 							"```diff\n%s\n```\n", | ||||||
| 							diffOutput, | 							diffOutput, | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user