git-release-manager
Version:
A tool to generate release notes from git commit history
170 lines • 6.6 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BranchController = void 0;
const configManager_1 = require("../../config/configManager");
const BranchManager_1 = require("../../modules/branch/BranchManager");
class BranchController {
constructor() {
this.branchManager = new BranchManager_1.BranchManager();
}
async handleCreateCommand(options) {
try {
// const config = await readConfig(options.config, options.environment);
if (options.name) {
await this.branchManager.createBranch(options.name, options.basedOn, options.switch);
}
else {
console.log('Please specify an option for branch management.');
process.exit(1);
}
}
catch (error) {
console.error('Error:', error instanceof Error ? error.message : String(error));
process.exit(1);
}
}
async handleDeleteCommand(options) {
try {
const config = await (0, configManager_1.readConfig)(options.config, options.environment);
if (options.name) {
await this.branchManager.deleteBranch(options.name);
}
else {
console.log('Please specify an option for branch management.');
process.exit(1);
}
}
catch (error) {
console.error('Error:', error instanceof Error ? error.message : String(error));
process.exit(1);
}
}
async handleMergeCommand(options) {
try {
const config = await (0, configManager_1.readConfig)(options.config, options.environment);
if (options.name) {
await this.branchManager.mergeBranch(config, options.name, options.squash);
}
else {
console.log('Please specify an option for branch management.');
process.exit(1);
}
}
catch (error) {
console.error('Error:', error instanceof Error ? error.message : String(error));
process.exit(1);
}
}
async handleRebaseCommand(options) {
try {
const config = await (0, configManager_1.readConfig)(options.config, options.environment);
if (options.name) {
await this.branchManager.rebaseBranch(config, options.name);
}
else {
console.log('Please specify an option for branch management.');
process.exit(1);
}
}
catch (error) {
console.error('Error:', error instanceof Error ? error.message : String(error));
process.exit(1);
}
}
async handleSwitchCommand(options) {
try {
if (options.name) {
await this.branchManager.switchBranch(options.name);
}
else {
console.log('Please specify an option for branch management.');
process.exit(1);
}
}
catch (error) {
console.error('Error:', error instanceof Error ? error.message : String(error));
process.exit(1);
}
}
async handleProtectCommand(options) {
try {
await this.branchManager.protectBranch(options.name);
}
catch (error) {
console.error('Error:', error instanceof Error ? error.message : String(error));
process.exit(1);
}
}
async handleUnProtectCommand(options) {
try {
await this.branchManager.unprotectBranch(options.name);
}
catch (error) {
console.error('Error:', error instanceof Error ? error.message : String(error));
process.exit(1);
}
}
async handleListCommand(options) {
try {
const config = await (0, configManager_1.readConfig)(options.config, options.environment);
await this.branchManager.listBranches(config, options.remote);
}
catch (error) {
console.error('Error:', error instanceof Error ? error.message : String(error));
process.exit(1);
}
}
async handleCommand(options, config) {
try {
const config = await (0, configManager_1.readConfig)(options.config, options.environment);
if (options.create) {
// await this.branchManager.createBranch(options.create, options.push)
// } else if (options.delete) {
// await this.branchManager.deleteBranch(options.delete)
}
else if (options.list) {
// await this.branchManager.listBranches()
}
else if (options.switch) {
// await this.branchManager.switchBranch(options.switch)
}
else if (options.merge) {
// await this.branchManager.mergeBranch(options.merge, options.push)
}
else if (options.release) {
await this.branchManager.createReleaseBranch(config, options.release, options.push);
}
else if (options.hotfix) {
await this.branchManager.createHotfixBranch(config, options.hotfix, options.push);
}
else if (options.feature) {
await this.branchManager.createFeatureBranch(config, options.feature, options.push);
}
else if (options.finish) {
await this.branchManager.finishBranch(config, options.finish, options.push);
}
else if (options.protect) {
// await this.branchManager.protectBranch(options.protect)
}
else if (options.unprotect) {
// await this.branchManager.unprotectBranch(options.unprotect)
}
else if (options.rebase) {
// await this.branchManager.rebaseBranch(options.rebase, options.push)
}
else if (options.sync) {
await this.branchManager.syncBranch(config, options.push);
}
else {
console.log('Please specify an option for branch management.');
process.exit(1);
}
}
catch (error) {
console.error('Error:', error instanceof Error ? error.message : String(error));
process.exit(1);
}
}
}
exports.BranchController = BranchController;
//# sourceMappingURL=BranchController.js.map