"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const core_1 = require("@oclif/core");
const inquirer = require("inquirer");
const command_base_tenantless_1 = require("../command-base-tenantless");
class Merge extends command_base_tenantless_1.CommandBaseTenantless {
    run() {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            return new Promise((resolve, reject) => tslib_1.__awaiter(this, void 0, void 0, function* () {
                try {
                    this.bootstrap();
                    const { args, flags } = yield this.parse(Merge);
                    let branch = args.branch;
                    if (!branch /* ...or not a valid branch name */) {
                        // TODO: pick from a list (be sure to filter out the current branch from the list)
                        //       and cancel if there are no branches available.
                        let result = yield inquirer.prompt({ type: "input", name: "branch", message: "Enter the branch to merge into the current one: \n(ctrl-c to cancel) " });
                        branch = result.branch;
                    }
                    if (branch) {
                        yield this._ops.gitMerge(branch, flags.commit);
                    }
                    resolve();
                }
                catch (err) {
                    this.handleError(err);
                    reject(err);
                }
            }));
        });
    }
}
exports.default = Merge;
Merge.description = 'Merges the given branch into the current branch of the main project and on any sourced dependencies.';
Merge.flags = {
    help: core_1.Flags.help({ char: 'h' }),
    commit: core_1.Flags.boolean({ char: 'c', description: 'Commits if merge succeeds.', default: false })
};
Merge.args = {
    branch: core_1.Args.string({ description: 'The branch name to merge into the current one.', require: false })
};
//# sourceMappingURL=merge.js.map