gitoria

kunibert

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Main branchmainbd3591c7conductor: gates run on the live day44 binarymremain/lib/review-vendored.hl

3.5 KB

  1. $mode = 'static'
  2. import { run } from 'hl:proc'
  3. import { require } from './review-output.hl'
  4. // Read the optional ignore file from the exact PR HEAD, also before a worktree exists.
  5. vendoredPaths = (String repo, String head, Hybrid configured) => {
  6. prefixes = []
  7. for (p of configured) { if (p != '' && !prefixes.includes(p)) { prefixes.push(p) } }
  8. names = run(['git', 'ls-tree', '--name-only', head, '--', '.kunibertignore'], { cwd = repo, timeout = 30 })
  9. require(names.exit == 0, 'cannot look up .kunibertignore at PR head')
  10. if (!names.lines.includes('.kunibertignore')) { return prefixes }
  11. file = run(['git', 'show', head + ':.kunibertignore'], { cwd = repo, timeout = 30 })
  12. require(file.exit == 0, 'cannot read .kunibertignore at PR head')
  13. for (line of file.lines) {
  14. p = line.trim()
  15. if (p != '' && !p.startsWith('#') && !prefixes.includes(p)) { prefixes.push(p) }
  16. }
  17. return prefixes
  18. }
  19. isVendored = (String path, Hybrid prefixes) => {
  20. for (p of prefixes) { if (path.startsWith(p)) { return true } }
  21. return false
  22. }
  23. // The PR diff without vendored files: used when the full diff is over the size limit (jukebox PR #9, a framework bump).
  24. // A rename or copy with one app side keeps both sides, so git still shows it as a rename.
  25. appDiff = (String repo, String range, Hybrid prefixes) => {
  26. names = run(['git', 'diff', '--no-ext-diff', '--name-status', '-z', '-M', range, '--'], { cwd = repo, timeout = 30 })
  27. require(names.exit == 0, 'cannot list the changed files')
  28. nul = JSON.parse('"\u0000"')
  29. items = names.lines.join('
  30. ').split(nul)
  31. paths = []
  32. let i = 0
  33. while (i < items.length && items[i] != '') {
  34. status = items[i]
  35. pair = [items[i + 1]]
  36. i = i + 2
  37. if (status.startsWith('R') || status.startsWith('C')) { pair.push(items[i]) i = i + 1 }
  38. let app = false
  39. for (p of pair) { if (!isVendored(p, prefixes)) { app = true } }
  40. if (app) { for (p of pair) { paths.push(p) } }
  41. }
  42. if (paths.length == 0) { return '' }
  43. d = run(['git', '--literal-pathspecs', 'diff', '--no-ext-diff', '--no-textconv', '-M', range, '--'] + paths, { cwd = repo, timeout = 30 })
  44. require(d.exit == 0, 'cannot read the app diff')
  45. return d.lines.join('
  46. ')
  47. }
  48. // Keep old keys stable, but settle these threads before thread updates and wake prompts.
  49. settleVendored = (Hybrid state, Hybrid prefixes) => {
  50. for (let i = 0; i < state.threads.length; i = i + 1) {
  51. t = state.threads[i]
  52. if (isVendored(t.path, prefixes)) {
  53. t.vendored = true
  54. t.settled = true
  55. if (!state.settled.includes(t.key)) { state.settled.push(t.key) }
  56. state.threads[i] = t
  57. }
  58. }
  59. return state
  60. }
  61. // Only app findings enter applyResult: framework findings never get a thread key.
  62. appResult = (Hybrid result, Hybrid prefixes, Hybrid state, String link) => {
  63. app = []
  64. framework = []
  65. for (f of result.findings) {
  66. if (isVendored(f.path, prefixes)) { framework.push(f) } else { app.push(f) }
  67. }
  68. replies = []
  69. for (r of result.replies) {
  70. let vendored = false
  71. for (t of state.threads) { if (t.key == r.thread && t.vendored) { vendored = true } }
  72. if (!vendored) { replies.push(r) }
  73. }
  74. result.findings = app
  75. result.framework = framework
  76. result.replies = replies
  77. result.vendoredLink = link
  78. if (prefixes.length > 0) {
  79. result.verdict = app.length == 0 ? 'approve' : 'comment'
  80. for (f of app) { if (f.severity == 'blocker' || f.severity == 'major') { result.verdict = 'request_changes' } }
  81. }
  82. return result
  83. }

Branches

Latest commits

  • bd3591c7conductor: gates run on the live day44 binarymre
  • 47f747a7records: jukebox #9 fix livemre
  • 0a3169fdMerge branch 'vendored-size' into mainKunibert
  • e447bb09Vendored size fix: keep renames with an app side whole; type the filter parameter (L10)mre
  • 99ccc742Vendored size fix: no renames in the app diff, filter the resumed delta toomre
  • 1a52e100|||PR Diff size limit counts only app files when vendored paths are setmre
  • 50a1867estatus: jukebox #9mre
  • c57484e6log: jukebox #9 diff sizemre
  • 795a20carecords: guard fix live (PR 8)mre
  • 6981d96fMerge branch 'fresh-on-nocmd' into mainKunibert
  • 37c47840runner: one shared prompt for both fresh-session fallbacks (L16)mre
  • f945d2e1|||PR runner: a resumed run with no command on a new head gets one fresh session instead of a tool errormre
  • 10b2a49estatus: PR 314, guard fix proposedmre
  • e73995a3log: hycon PR 314 approved after fresh reviewmre
  • f60427falog: hycon PR 314 false tool errormre
  • 481974f7log: Hermes accepts PR 259 findingmre
  • bb0976acrecords: hycon PR 259 design findingmre
  • 5c637c24records: hycon PR 259 false tool errormre
  • a344c406log: routger 132 reviewedmre
  • 56e70dcbrecords: review time limit 1800 s (routger 132)mre