Module: Carson::Runtime::Deliver
- Included in:
- Carson::Runtime
- Defined in:
- lib/carson/runtime/deliver.rb
Instance Method Summary collapse
-
#deliver!(title: nil, body_file: nil, commit_message: nil, json_output: false) ⇒ Object
Entry point for ‘carson deliver`.
Instance Method Details
#deliver!(title: nil, body_file: nil, commit_message: nil, json_output: false) ⇒ Object
Entry point for ‘carson deliver`. Pushes the current branch, ensures a PR exists, records delivery state, and returns. When –commit is supplied, Carson creates one all-dirty agent-authored commit first.
9 10 11 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 40 41 42 43 44 45 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 |
# File 'lib/carson/runtime/deliver.rb', line 9 def deliver!( title: nil, body_file: nil, commit_message: nil, json_output: false ) branch_name = current_branch main_branch = config.main_branch remote_name = config.git_remote result = { command: "deliver", branch: branch_name } if branch_name == main_branch result[ :error ] = "cannot deliver from #{main_branch}" result[ :recovery ] = "carson worktree create <name>" return deliver_finish( result: result, exit_code: EXIT_BLOCK, json_output: json_output ) end initial_dirty = working_tree_dirty? if initial_dirty && .to_s.strip.empty? result[ :error ] = "working tree is dirty" result[ :recovery ] = "carson deliver --commit \"describe this delivery\"" return deliver_finish( result: result, exit_code: EXIT_BLOCK, json_output: json_output ) end if !initial_dirty && !.to_s.strip.empty? result[ :commit ] = blocked_commit_payload( message: , summary: "blocked — working tree is already clean" ) result[ :error ] = "working tree is already clean" result[ :recovery ] = "carson deliver" return deliver_finish( result: result, exit_code: EXIT_BLOCK, json_output: json_output ) end sync_exit, sync_diagnostics = deliver_template_sync if sync_exit == EXIT_ERROR result[ :error ] = sync_diagnostics.to_s.strip.empty? ? "template sync failed" : sync_diagnostics.strip return deliver_finish( result: result, exit_code: sync_exit, json_output: json_output ) end template_sync_committed = sync_exit == EXIT_BLOCK unless .to_s.strip.empty? commit_exit = prepare_delivery_commit!( commit_message: , template_sync_committed: template_sync_committed, result: result ) return deliver_finish( result: result, exit_code: commit_exit, json_output: json_output ) unless commit_exit == EXIT_OK end push_exit = push_branch!( branch: branch_name, remote: remote_name, result: result ) return deliver_finish( result: result, exit_code: push_exit, json_output: json_output ) unless push_exit == EXIT_OK pr_number, pr_url = find_or_create_pr!( branch: branch_name, title: title, body_file: body_file, result: result ) return deliver_finish( result: result, exit_code: EXIT_ERROR, json_output: json_output ) if pr_number.nil? branch = branch_record( name: branch_name ) delivery = ledger.upsert_delivery( repository: repository_record, branch_name: branch.name, head: branch.head || current_head, worktree_path: branch.worktree || repo_root, authority: config., pr_number: pr_number, pr_url: pr_url, status: "preparing", summary: "delivery accepted", cause: nil ) delivery = assess_delivery!( delivery: delivery, branch_name: branch.name ) result[ :pr_number ] = pr_number result[ :pr_url ] = pr_url result[ :ci ] = check_pr_ci( number: pr_number ).to_s result[ :delivery ] = delivery_payload( delivery: delivery ) result[ :summary ] = delivery.summary result[ :next_step ] = "carson status" deliver_finish( result: result, exit_code: EXIT_OK, json_output: json_output ) end |