@@ -48,15 +48,29 @@ jobs:
48
48
with :
49
49
github-token : ${{ secrets.GITHUB_TOKEN }}
50
50
script : |
51
+ const MAX_CHARACTERS = 30000
52
+ const MAX_CHARACTERS_PER_PROJECT = MAX_CHARACTERS / 3
53
+
51
54
const fs = require('fs')
52
55
let data = fs.readFileSync('fulldiff.txt', { encoding: 'utf8' })
53
- // posting comment fails if too long, so truncate
54
- if (data.length > 30000) {
55
- let truncated_data = data.substring(0, 30000)
56
- let lines_truncated = data.split('\n').length - truncated_data.split('\n').length
57
- data = truncated_data + `\n\n... (truncated ${lines_truncated} lines) ...\n`
56
+
57
+ function truncateIfNeeded(original, maxLength) {
58
+ if (original.length <= maxLength) {
59
+ return original
60
+ }
61
+ let truncated = original.substring(0, maxLength)
62
+ // further, remove last line that might be truncated
63
+ truncated = truncated.substring(0, truncated.lastIndexOf('\n'))
64
+ let lines_truncated = original.split('\n').length - truncated.split('\n').length
65
+ return `${truncated}\n\n... (truncated ${lines_truncated} lines) ...`
58
66
}
59
67
68
+ const projects = data.split('\n\n')
69
+ // don't let one project dominate
70
+ data = projects.map(project => truncateIfNeeded(project, MAX_CHARACTERS_PER_PROJECT)).join('\n\n')
71
+ // posting comment fails if too long, so truncate
72
+ data = truncateIfNeeded(data, MAX_CHARACTERS)
73
+
60
74
console.log("Diff from mypy_primer:")
61
75
console.log(data)
62
76
0 commit comments