"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ensureParentIssueBranchRemoteRef = ensureParentIssueBranchRemoteRef;
const default_issue_workspace_manager_1 = require("../../workspaces/default-issue-workspace-manager");
const issue_branch_target_1 = require("./issue-branch-target");
async function ensureParentIssueBranchRemoteRef(input) {
    const branchName = (0, default_issue_workspace_manager_1.resolveIssueBranchName)(input.context.config.branchPrefix, input.parentIssue);
    const baseBranch = (0, issue_branch_target_1.resolveIssueRunBaseBranch)(input.workflowState);
    const workspace = await input.context.issueWorkspaceManager.ensureWorkspace({
        repositoryRoot: input.context.cwd,
        repositoryHost: input.context.config.repositoryHost,
        ticketTracker: input.context.config.ticketTracker,
        issueId: input.parentIssue.id,
        branchName,
        baseBranch,
    });
    await input.context.gitRepository.pushBranch(workspace.path, branchName, {
        hookContext: "worker",
    });
}
