gitoria

kunibert

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitb143c3c7b143c3c7CONDUCTOR: push recipemreb143c3c7/lib/gitoria-events.hl

3.8 KB

  1. $mode = 'static'
  2. \\ THE ONE FILE that knows gitoria's event names and field paths (apps-api.md v0, section 4).
  3. \\ When the contract changes (the [OPEN] marks), only this file changes.
  4. headerEvent = 'x-push-event'
  5. headerDelivery = 'x-push-delivery'
  6. headerSignature = 'x-push-signature-256'
  7. signaturePrefix = 'sha256='
  8. eventNames = ['ping', 'pull_request', 'review_requested', 'review_comment', 'pull_comment', 'review_thread']
  9. botMention = '@kunibert'
  10. isKnown = (name) => {
  11. return name != null && eventNames.includes(name)
  12. }
  13. \\ the repo id the secret is keyed by; null when the body has none
  14. repoId = (body) => {
  15. if (body.repo == null || body.repo.id == null) { return null }
  16. return '' + body.repo.id
  17. }
  18. \\ `@kunibert reset` / `@kunibert <text>` at the start of a comment: { reset } or { note } or null
  19. mention = (text) => {
  20. if (hlTypeName(text) != 'String') { return null }
  21. t = text.trim()
  22. if (!t.toLowerCase().startsWith(botMention)) { return null }
  23. rest = t.slice(botMention.length).trim()
  24. if (rest == '') { return null }
  25. if (rest.toLowerCase() == 'reset') { return { reset = true } }
  26. return { note = rest }
  27. }
  28. \\ A change a job can use, from one parsed event. Answer: { kind, reason, ... }
  29. \\ kind: 'ignore' | 'ping' | 'review' | 'thread-state' | 'close'
  30. \\ A review/thread-state change carries: repo, number, head, time, pull, force, reset, threads, notes, replyCandidate.
  31. \\ review: starts or updates a review job. thread-state: only records a resolved/settled flip (no review).
  32. \\ replyCandidate: a review_comment; the queue makes it threadReplyOnly when it brings no new head.
  33. classify = (String name, Hybrid body) => {
  34. action = body.action
  35. pull = body.pull
  36. if (name == 'ping') { return { kind = 'ping' } }
  37. if (pull == null || pull.number == null || repoId(body) == null) { return { kind = 'ignore', reason = 'no repo.id or pull.number' } }
  38. change = {
  39. kind = 'review'
  40. repoId = repoId(body)
  41. repo = body.repo
  42. number = pull.number
  43. head = pull.head
  44. time = body.time
  45. pull = pull
  46. force = false
  47. reset = false
  48. threads = []
  49. notes = []
  50. delivery = body.delivery
  51. event = name + '.' + action
  52. replyCandidate = false
  53. }
  54. if (name == 'pull_request') {
  55. if (action == 'closed' || action == 'merged') { change.kind = 'close'
  56. return change }
  57. if (pull.draft == true) { return { kind = 'ignore', reason = 'draft pull request' } }
  58. if (action == 'opened' || action == 'reopened' || action == 'synchronize' || action == 'ready') { return change }
  59. return { kind = 'ignore', reason = 'pull_request.' + action + ' not handled' }
  60. }
  61. if (pull.draft == true) { return { kind = 'ignore', reason = 'draft pull request' } }
  62. if (name == 'review_requested') {
  63. change.reset = true
  64. change.force = true
  65. return change
  66. }
  67. if (name == 'review_comment' && action == 'created') {
  68. change.threads.push({ event = 'review_comment.created', thread = body.thread, comment = body.comment })
  69. change.replyCandidate = true
  70. return change
  71. }
  72. if (name == 'review_thread' && (action == 'resolved' || action == 'unresolved')) {
  73. change.threads.push({ event = 'review_thread.' + action, thread = body.thread })
  74. change.kind = 'thread-state'
  75. return change
  76. }
  77. if (name == 'pull_comment' && action == 'created') {
  78. let m = null
  79. if (body.comment != null) { m = mention(body.comment.body) }
  80. if (m == null) { return { kind = 'ignore', reason = 'comment without @kunibert' } }
  81. if (m.reset) { change.reset = true change.force = true }
  82. if (m.note != null) { change.force = true change.notes.push({ text = m.note, by = body.comment.author }) }
  83. return change
  84. }
  85. return { kind = 'ignore', reason = name + '.' + action + ' not handled' }
  86. }

Branches

Latest commits

  • b143c3c7CONDUCTOR: push recipemre
  • 7a1279eeRule: conductor merges own utility PRs after green reviewmre
  • 4038b3e0Log: kunibert#18 openedmre
  • 18543db1Log: day42 fetch fix, re-vendor pendingmre
  • 81a12f96Statusmre
  • 6ce706abRecords: neutral wording, split cleanupmre
  • 81a4d31bDocs: neutral wordingKunibert
  • 8205b05eRecords: #17 livemre
  • c3391204Answer fresh reviews under open threadsKunibert
  • a0f3d147Records: #16 livemre
  • 04322148Run reviews in parallel across repositoriesKunibert
  • a6577aaeRecords: #14 live, #16 startedmre
  • 0382238bStart fresh on Review again and name vendored pathsKunibert
  • 5608c6f1Records: kunibert#13 vendored paths livemre
  • 8840771dExclude vendored findings from app verdictsKunibert
  • 6aa65353Records: jukebox connected, first reviewmre
  • ad8011cfRecords: neutral ticket rule, jukeboxmre
  • ca5f31dfPrompt: neutral reviewer identitymre
  • b241d9c8Records: Anton tryParse noteKunibert
  • 42cc1bc0Records: K12 doneKunibert