Skip to content

Commit 649544b

Browse files
Merge pull request #1827 from contentstack/fix/DX-1328
fix: added missing branch flag handling
2 parents f6cf555 + 999db3e commit 649544b

File tree

1 file changed

+16
-0
lines changed
  • packages/contentstack-import/src/commands/cm/stacks

1 file changed

+16
-0
lines changed

packages/contentstack-import/src/commands/cm/stacks/import.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,22 @@ export default class ImportCommand extends Command {
148148
backupDir = importConfig.cliLogsPath || importConfig.backupDir;
149149

150150
const managementAPIClient: ContentstackClient = await managementSDKClient(importConfig);
151+
152+
if (!flags.branch) {
153+
try {
154+
const branches = await managementAPIClient
155+
.stack({ api_key: importConfig.apiKey })
156+
.branch()
157+
.query()
158+
.find()
159+
.then(({ items }: any) => items)
160+
if (branches.length) {
161+
flags.branch = 'main';
162+
}
163+
} catch (error) {
164+
// Branch not enabled, just the let flow continue
165+
}
166+
}
151167
const moduleImporter = new ModuleImporter(managementAPIClient, importConfig);
152168
const result = await moduleImporter.start();
153169

0 commit comments

Comments
 (0)