Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(export), fix output to show the exported lane in case no new snaps added #9175

Merged
merged 2 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 e2e/harmony/lanes/lanes.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ describe('bit lane command', function () {
expect(status.invalidComponents[0].error.name).to.equal('NoCommonSnap');
});
it('should be able to export with no error', () => {
expect(() => helper.command.export('--fork-lane-new-scope')).to.not.throw();
expect(() => helper.command.export('--fork-lane-new-scope --all')).to.not.throw();
});
});
describe('snapping and un-tagging on a lane', () => {
Expand Down
5 changes: 3 additions & 2 deletions scopes/scope/export/export-cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,12 @@ export class ExportCmd implements Command {
ignoreMissingArtifacts,
forkLaneNewScope,
});
if (isEmpty(componentsIds) && isEmpty(nonExistOnBitMap) && isEmpty(missingScope)) {
if (isEmpty(componentsIds) && isEmpty(nonExistOnBitMap) && isEmpty(missingScope) && !exportedLanes.length) {
return chalk.yellow('nothing to export');
}
const exportedLane = exportedLanes[0]?.id();
const exportOutput = () => {
if (isEmpty(componentsIds)) return '';
if (isEmpty(componentsIds)) return exportedLane ? `exported the lane ${chalk.bold(exportedLane)}` : '';
const lanesOutput = exportedLanes.length ? ` the lane ${chalk.bold(exportedLanes[0].id())} and` : '';
return chalk.green(
`exported${lanesOutput} the following ${componentsIds.length} component(s):\n${chalk.bold(
Expand Down
6 changes: 5 additions & 1 deletion scopes/scope/export/export.main.runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export class ExportMain {
includeNonStaged || headOnly
);

if (!idsToExport.length) {
if (!idsToExport.length && !laneObject) {
return {
updatedIds: [],
nonExistOnBitMap: [],
Expand All @@ -148,6 +148,10 @@ export class ExportMain {
rippleJobs: [],
};
}
if (!idsToExport.length && laneObject && params.forkLaneNewScope) {
throw new BitError(`the forked lane "${laneObject.name}" has no changes, to export all its components, please use "--all" flag
if the export fails with missing objects/versions/components, run "bit fetch --lanes <lane-name> --all-history", to make sure you have the full history locally`);
}

// validate lane readme component and ensure it has been snapped
if (laneObject?.readmeComponent) {
Expand Down