brainiac-basecamp 0.0.14 → 0.0.15
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/basecamp/hooks.rb +44 -4
- data/lib/brainiac/plugins/basecamp/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: e8e71f8f043a52cb54d83e974031b0bb83339f02452e701bf381e4e87b32274d
|
|
4
|
+
data.tar.gz: ac57b522a30cdb3cdf42c0aca069c52bb1ce27b2b93fdbdf4b63a2c9f57088b9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 955cfcffe81b1856b0ee90e8c2124b48d13b3de28db1e258054069442b8a67096deeb95cda1b5ce0e21b20cd2b78e3bd7c73fd107c5753c3de82ef0ead916d01
|
|
7
|
+
data.tar.gz: 7b6e92a54b136065013d178d3422bc7583958f83b161184c9905b2d950898907ee1eebdffa6d2cf07bc7394836b98aef52acd8bb50583231b2b6b8f2f9ca3247
|
|
@@ -16,7 +16,7 @@ module Brainiac
|
|
|
16
16
|
# :resolve_base_branch — returns epic branch as worktree base
|
|
17
17
|
# :resolve_pr_target — returns epic branch as PR target
|
|
18
18
|
module Hooks
|
|
19
|
-
class << self
|
|
19
|
+
class << self # rubocop:disable Metrics/ClassLength
|
|
20
20
|
def register_all!
|
|
21
21
|
register_agent_completed
|
|
22
22
|
register_pr_merged
|
|
@@ -380,14 +380,39 @@ module Brainiac
|
|
|
380
380
|
next unless epic["review_gate"] == "epic_branch" && ReviewGate.enabled?
|
|
381
381
|
|
|
382
382
|
task = epic["tasks"].find { |t| t["fizzy_card"] == card_number.to_i }
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
383
|
+
next unless task && task["status"] == "in_flight"
|
|
384
|
+
|
|
385
|
+
# Ensure pr_number is set — it may be missing if initial gate dispatch
|
|
386
|
+
# failed to persist it or if state was lost during serialization.
|
|
387
|
+
unless task["pr_number"]
|
|
388
|
+
pr_number = ctx.dig(:pull_request, "number") || ctx[:pr_number]
|
|
389
|
+
if pr_number
|
|
390
|
+
task["pr_number"] = pr_number.to_i
|
|
391
|
+
LOG.info "[Basecamp:Hooks] Backfilled pr_number=#{pr_number} for card ##{card_number}" if defined?(LOG)
|
|
392
|
+
else
|
|
393
|
+
# Try to find it from the branch
|
|
394
|
+
project_key = task["project"] || Config.brainiac_project_for(epic["basecamp_project_id"])
|
|
395
|
+
projects_file = File.join(ENV.fetch("BRAINIAC_DIR", File.join(Dir.home, ".brainiac")), "projects.json")
|
|
396
|
+
projects = File.exist?(projects_file) ? JSON.parse(File.read(projects_file)) : {}
|
|
397
|
+
repo_path = projects.dig(project_key, "repo_path")
|
|
398
|
+
if repo_path
|
|
399
|
+
branch = ctx[:branch] || "fizzy-#{card_number}-*"
|
|
400
|
+
found_pr = find_pr_number(repo_path: repo_path, branch: branch)
|
|
401
|
+
if found_pr
|
|
402
|
+
task["pr_number"] = found_pr
|
|
403
|
+
LOG.info "[Basecamp:Hooks] Resolved pr_number=#{found_pr} for card ##{card_number} via branch lookup" if defined?(LOG)
|
|
404
|
+
end
|
|
405
|
+
end
|
|
406
|
+
end
|
|
407
|
+
end
|
|
408
|
+
|
|
409
|
+
next unless task["pr_number"]
|
|
386
410
|
|
|
387
411
|
LOG.info "[Basecamp:Hooks] PR updated for card ##{card_number} — re-triggering review gates" if defined?(LOG)
|
|
388
412
|
|
|
389
413
|
# Reset approvals and re-dispatch gates
|
|
390
414
|
ReviewGate.reset_approvals(task)
|
|
415
|
+
task["changes_requested_by"] = []
|
|
391
416
|
task["status"] = "in_review"
|
|
392
417
|
epic["updated_at"] = Time.now.iso8601
|
|
393
418
|
save_epic_state(epic)
|
|
@@ -821,6 +846,21 @@ module Brainiac
|
|
|
821
846
|
return
|
|
822
847
|
end
|
|
823
848
|
|
|
849
|
+
# Ensure pr_number is set — look it up if missing.
|
|
850
|
+
# This is critical for the pr_synchronized hook to re-trigger gates after fixes.
|
|
851
|
+
unless pr_number
|
|
852
|
+
found_pr = find_pr_number(repo_path: repo_path, branch: "fizzy-#{card_number}-*")
|
|
853
|
+
if found_pr
|
|
854
|
+
pr_number = found_pr
|
|
855
|
+
task["pr_number"] = pr_number
|
|
856
|
+
task["pr_repo"] = project_config["github_repo"]
|
|
857
|
+
save_epic_state(epic)
|
|
858
|
+
LOG.info "[Basecamp:Hooks] Backfilled pr_number=#{pr_number} for card ##{card_number} during direct dispatch" if defined?(LOG)
|
|
859
|
+
elsif defined?(LOG)
|
|
860
|
+
LOG.warn "[Basecamp:Hooks] Could not find PR for card ##{card_number} — gates won't re-trigger after fixes"
|
|
861
|
+
end
|
|
862
|
+
end
|
|
863
|
+
|
|
824
864
|
# Find the worktree for this card
|
|
825
865
|
work_items_file = File.join(ENV.fetch("BRAINIAC_DIR", File.join(Dir.home, ".brainiac")), "work_items.json")
|
|
826
866
|
worktree_path = repo_path # Default to main repo
|