brainiac-github 0.2.7 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/brainiac/plugins/github/handler.rb +48 -12
- data/lib/brainiac/plugins/github/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: db8e2a2ac41b7a6fe786239a6a909aac61975a70273068c243b301eeb2407f93
|
|
4
|
+
data.tar.gz: 8427ed0cbf86df7198149a11cbf64309471dea9ce9293ad9a49db57f2d14a03d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e385a16a159af98f746a0c7ada60c04802de2549d8ace8a37ee8830ad8886d9bf5fa5ba89a34d38ba69b21c4b6aa82b0a1d24114a950e19bd10b5f7a45f9877d
|
|
7
|
+
data.tar.gz: 43cc967f3aafd227715a82e2a366e289452e0136e29415a52d244b0e796b9355f72983b1b32a056c86707a820dad269f9c2cfa9324d96945580c6574f6554685
|
|
@@ -285,18 +285,22 @@ module Brainiac
|
|
|
285
285
|
# If the work item's assigned agent is NOT local to this machine,
|
|
286
286
|
# skip dispatch entirely — the other machine owns this PR's agent.
|
|
287
287
|
if result && !mentioned
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
288
|
+
override_result = resolve_comment_agent_override(result, agent_name, pr_number)
|
|
289
|
+
return override_result if override_result.is_a?(Array)
|
|
290
|
+
|
|
291
|
+
agent_name = override_result if override_result
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
# Fallback for human-opened PRs with no assigned agent: if there's no work item,
|
|
295
|
+
# or the work item has no agent field, both machines would dispatch because each
|
|
296
|
+
# has its own local project default agent. Use branch_exists_locally? as a
|
|
297
|
+
# tiebreaker — only the machine that has the branch as a local worktree/branch
|
|
298
|
+
# should handle the comment. Explicit mentions bypass this check.
|
|
299
|
+
unless mentioned || work_item_has_agent?(result)
|
|
300
|
+
repo_path = project_config["repo_path"]
|
|
301
|
+
unless branch_exists_locally?(repo_path, branch)
|
|
302
|
+
LOG.info "[GitHub] PR ##{pr_number} branch '#{branch}' not found locally — skipping comment dispatch"
|
|
303
|
+
return [200, { status: "ignored", reason: "branch not on this machine" }.to_json]
|
|
300
304
|
end
|
|
301
305
|
end
|
|
302
306
|
|
|
@@ -404,6 +408,38 @@ module Brainiac
|
|
|
404
408
|
local_agent_names.include?(agent_from_bot)
|
|
405
409
|
end
|
|
406
410
|
|
|
411
|
+
# Check if a work item result has an assigned agent.
|
|
412
|
+
# Returns true if the result exists and has a non-empty agent field.
|
|
413
|
+
def work_item_has_agent?(result)
|
|
414
|
+
return false unless result
|
|
415
|
+
|
|
416
|
+
agent = result[1]["agent"]
|
|
417
|
+
agent && !agent.empty?
|
|
418
|
+
end
|
|
419
|
+
|
|
420
|
+
# Resolve agent override from a work item for PR comment dispatch.
|
|
421
|
+
# Returns:
|
|
422
|
+
# - A Rack response array if dispatch should be skipped (remote agent owns it)
|
|
423
|
+
# - An agent name string if the work item agent should override the default
|
|
424
|
+
# - nil if no override needed
|
|
425
|
+
def resolve_comment_agent_override(result, current_agent, pr_number)
|
|
426
|
+
_, card_info = result
|
|
427
|
+
work_item_agent = card_info["agent"]
|
|
428
|
+
return nil unless work_item_agent
|
|
429
|
+
|
|
430
|
+
unless local_agent_names.include?(work_item_agent)
|
|
431
|
+
LOG.info "[GitHub] PR ##{pr_number} assigned to remote agent #{work_item_agent} — skipping dispatch"
|
|
432
|
+
return [200, { status: "ignored", reason: "work item owned by remote agent" }.to_json]
|
|
433
|
+
end
|
|
434
|
+
|
|
435
|
+
if work_item_agent.downcase != current_agent.downcase
|
|
436
|
+
LOG.info "[GitHub] Work item agent override: #{work_item_agent} (project default: #{current_agent})"
|
|
437
|
+
return work_item_agent
|
|
438
|
+
end
|
|
439
|
+
|
|
440
|
+
nil
|
|
441
|
+
end
|
|
442
|
+
|
|
407
443
|
# Check if a branch exists as a local worktree or local branch.
|
|
408
444
|
# Used to determine if this machine should handle a PR when there's no work item.
|
|
409
445
|
#
|