Class: Ace::Git::Worktree::Molecules::PullRequestCreator
- Inherits:
-
Object
- Object
- Ace::Git::Worktree::Molecules::PullRequestCreator
- Defined in:
- lib/ace/git/worktree/molecules/pull_request_creator.rb
Overview
Creates draft pull requests for task worktrees through the forge-neutral provider contract.
The caller must supply the exact pushed head SHA (expected_head);
creation or reuse is proven against that SHA by the provider, never
inferred from branch names. Server selection resolves lazily inside
the lifecycle organism, so local-only task runs never touch a forge.
Instance Method Summary collapse
-
#create_draft(branch:, base:, title:, expected_head:, head_repository_url: nil, body: nil) ⇒ Hash
Create (or reconcile to) a draft PR for a pushed branch.
-
#initialize(server_name: nil, use_default: false, remote_name: nil, timeout: nil, runner: nil) ⇒ PullRequestCreator
constructor
A new instance of PullRequestCreator.
Constructor Details
#initialize(server_name: nil, use_default: false, remote_name: nil, timeout: nil, runner: nil) ⇒ PullRequestCreator
Returns a new instance of PullRequestCreator.
22 23 24 25 26 27 28 |
# File 'lib/ace/git/worktree/molecules/pull_request_creator.rb', line 22 def initialize(server_name: nil, use_default: false, remote_name: nil, timeout: nil, runner: nil) @selection = { server_name: server_name, use_default: use_default, remote_name: remote_name } @timeout = timeout @runner = runner end |
Instance Method Details
#create_draft(branch:, base:, title:, expected_head:, head_repository_url: nil, body: nil) ⇒ Hash
Create (or reconcile to) a draft PR for a pushed branch.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/ace/git/worktree/molecules/pull_request_creator.rb', line 40 def create_draft(branch:, base:, title:, expected_head:, head_repository_url: nil, body: nil) lifecycle = Ace::Git::Organisms::PullRequestLifecycle.new(**@selection.merge(timeout: @timeout, runner: @runner)) receipt = lifecycle.create( head_ref: branch, head_repository_url: head_repository_url, base_ref: base, expected_head: expected_head, title: title, body: body, draft: true ) pr = receipt.pull_request { success: true, pr_number: pr.number, pr_url: pr.url, existing: receipt.idempotency == :existing, head_sha: pr.head_sha, error: nil } rescue Ace::Git::Error => e {success: false, pr_number: nil, pr_url: nil, existing: false, head_sha: nil, error: e.} end |