Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/contentstack-branches/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli-cm-branches",
"description": "Contentstack CLI plugin to do branches operations",
"version": "1.3.0",
"version": "1.3.1",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
Expand Down
19 changes: 17 additions & 2 deletions packages/contentstack-branches/src/branch/merge-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import os from 'os';
import path from 'path';
import forEach from 'lodash/forEach';
import { cliux } from '@contentstack/cli-utilities';
import chalk from 'chalk';
import { MergeInputOptions, MergeSummary } from '../interfaces';
import {
selectMergeStrategy,
Expand Down Expand Up @@ -132,8 +133,11 @@ export default class MergeHandler {
} else if (this.strategy === 'overwrite_with_compare') {
this.mergeSettings.strategy = 'overwrite_with_compare';
}

await this.displayMergeSummary();
if (this.checkEmptySelection()) {
cliux.print(chalk.red('No items selected'));
} else {
await this.displayMergeSummary();
}

if (!this.executeOption) {
const executionResponse = await selectMergeExecution();
Expand All @@ -152,6 +156,17 @@ export default class MergeHandler {
}
}

checkEmptySelection() {
for (let module in this.branchCompareData) {
if (this.mergeSettings.mergeContent[module]?.modified?.length
|| this.mergeSettings.mergeContent[module]?.added?.length
|| this.mergeSettings.mergeContent[module]?.deleted?.length) {
return false;
}
}
return true;
}

displayMergeSummary() {
if (this.mergeSettings.strategy !== 'ignore') {
for (let module in this.branchCompareData) {
Expand Down
1 change: 1 addition & 0 deletions packages/contentstack-branches/src/interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface BranchDiffRes {
title: string;
type: string;
status: string;
merge_strategy?: string;
}

export interface BranchDiffSummary {
Comment thread
vkalta marked this conversation as resolved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ function printCompactTextView(branchTextRes: BranchCompactTextRes): void {
if (branchTextRes.modified?.length || branchTextRes.added?.length || branchTextRes.deleted?.length) {
cliux.print(' ');
forEach(branchTextRes.added, (diff: BranchDiffRes) => {
cliux.print(chalk.green(`+ '${diff.title}' ${startCase(camelCase(diff.type))}`));
if (diff.merge_strategy !== 'ignore') {
cliux.print(chalk.green(`+ '${diff.title}' ${startCase(camelCase(diff.type))}`));
}
});

forEach(branchTextRes.modified, (diff: BranchDiffRes) => {
Expand Down