Class: Aidp::Watch::RebaseProcessor
- Inherits:
-
BaseProcessor
- Object
- BaseProcessor
- Aidp::Watch::RebaseProcessor
- Defined in:
- lib/aidp/watch/rebase_processor.rb
Overview
Processor for handling 'aidp-rebase' label on GitHub PRs Automatically rebases the PR branch against its target branch
Constant Summary collapse
- DEFAULT_REBASE_LABEL =
"aidp-rebase".freeze
Instance Attribute Summary
Attributes inherited from BaseProcessor
Instance Method Summary collapse
- #can_process?(work_item) ⇒ Boolean
-
#initialize(repository_client:, state_store: nil, worktree_manager: nil, ai_decision_engine: AIDecisionEngine.new, label_config: {}, verbose: false, shell_executor: nil) ⇒ RebaseProcessor
constructor
A new instance of RebaseProcessor.
- #process(work_item) ⇒ Object
Constructor Details
#initialize(repository_client:, state_store: nil, worktree_manager: nil, ai_decision_engine: AIDecisionEngine.new, label_config: {}, verbose: false, shell_executor: nil) ⇒ RebaseProcessor
Returns a new instance of RebaseProcessor.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/aidp/watch/rebase_processor.rb', line 12 def initialize( repository_client:, state_store: nil, worktree_manager: nil, ai_decision_engine: AIDecisionEngine.new, label_config: {}, verbose: false, shell_executor: nil ) super( repository_client: repository_client, state_store: state_store, label_config: label_config, verbose: verbose ) @worktree_manager = worktree_manager || Aidp::PRWorktreeManager.new @ai_decision_engine = ai_decision_engine @shell_executor = shell_executor || Aidp::ShellExecutor.new @rebase_label = label_config[:rebase_trigger] || label_config["rebase_trigger"] || DEFAULT_REBASE_LABEL Aidp.log_debug( "rebase_processor", "initialized", rebase_label: @rebase_label ) end |
Instance Method Details
#can_process?(work_item) ⇒ Boolean
41 42 43 44 |
# File 'lib/aidp/watch/rebase_processor.rb', line 41 def can_process?(work_item) return false unless work_item.respond_to?(:pr?) && work_item.pr? work_item.labels.include?(@rebase_label) end |
#process(work_item) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/aidp/watch/rebase_processor.rb', line 46 def process(work_item) Aidp.log_debug( "rebase_processor", "processing_work_item", pr_number: work_item.number, branch: work_item.data[:head][:ref] ) begin # Fetch PR details pr_details = @repository_client.get_pull_request(work_item.number) base_branch = pr_details[:base][:ref] head_branch = pr_details[:head][:ref] # Create worktree for rebasing worktree_path = @worktree_manager.create_pr_worktree( pr_number: work_item.number, base_branch: base_branch, head_branch: head_branch ) # Attempt rebase with intelligent conflict resolution rebase_result = perform_rebase(worktree_path, base_branch, head_branch) # Post results to PR post_rebase_status(work_item.number, rebase_result) Aidp.log_debug( "rebase_processor", "rebase_completed", pr_number: work_item.number, result: rebase_result ) rebase_result rescue => e # Handle and log rebase failures handle_rebase_error(work_item.number, e) false ensure # Remove rebase label after processing (success or failure) @repository_client.remove_labels( work_item.number, [@rebase_label] ) # Cleanup: remove temporary worktree @worktree_manager.cleanup_pr_worktree(work_item.number) end end |