"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.configMigration = configMigration;
const logger_1 = require("../../../logger");
const branch_1 = require("./branch");
const migrated_data_1 = require("./branch/migrated-data");
const pr_1 = require("./pr");
async function configMigration(config, branchList) {
    if (config.configMigration) {
        if (config.mode === 'silent') {
            logger_1.logger.debug('Config migration issues are not created, updated or closed when mode=silent');
            return;
        }
        const migratedConfigData = await migrated_data_1.MigratedDataFactory.getAsync();
        const migrationBranch = await (0, branch_1.checkConfigMigrationBranch)(config, migratedConfigData); // null if migration not needed
        if (migrationBranch) {
            branchList.push(migrationBranch);
            await (0, pr_1.ensureConfigMigrationPr)(config, migratedConfigData);
        }
        migrated_data_1.MigratedDataFactory.reset();
    }
}
//# sourceMappingURL=index.js.map