"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkLocalBranch = void 0;
const exec_1 = require("./exec");
exports.checkLocalBranch = (directory) => {
    process.chdir(directory);
    const currentBranch = exec_1.exec(`git rev-parse --abbrev-ref HEAD`).stdout;
    const branch = exec_1.exec("echo ${CIRCLE_BRANCH:-$(git rev-parse --abbrev-ref HEAD)}").stdout;
    if (currentBranch === "HEAD") {
        console.log(`Currently in headless state, checking out branch ${branch}`);
        exec_1.exec(`git fetch --all`, false);
        exec_1.exec(`git checkout ${branch}`, false);
    }
    return { branch, currentBranch };
};
//# sourceMappingURL=checkLocalBranch.js.map