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

change "bit lane merge main" default to include non-lane components #8279

Merged
merged 1 commit into from
Dec 18, 2023
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
9 changes: 7 additions & 2 deletions e2e/harmony/lanes/merge-lanes.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,17 @@ describe('merge lanes', function () {
helper.command.tagAllWithoutBuild();
helper.command.export();
helper.command.createLane('dev');
helper.command.mergeLane('main', '-x');
});
it('should not bring non-lane components from main', () => {
it('when using --exclude-non-lane-comps flag, it should not bring non-lane components from main', () => {
helper.command.mergeLane('main', '-x --exclude-non-lane-comps');
const lane = helper.command.showOneLaneParsed('dev');
expect(lane.components).to.have.lengthOf(0);
});
it('by default, it should bring non-lane components from main', () => {
helper.command.mergeLane('main', '-x');
const lane = helper.command.showOneLaneParsed('dev');
expect(lane.components).to.have.lengthOf(1);
});
});
describe('merging main lane with no snapped components', () => {
let mergeOutput: string;
Expand Down
9 changes: 5 additions & 4 deletions scopes/component/checkout/checkout-cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ export class CheckoutCmd implements Command {
helpUrl = 'reference/components/merging-changes#checkout-snaps-to-the-working-directory';
group = 'development';
extendedDescription = `
\`bit checkout <version> [component-pattern]\` => checkout the specified ids (or all components when --all is used) to the specified version
\`bit checkout head [component-pattern]\` => checkout to the last snap/tag (use --latest if you only want semver tags), omit [component-pattern] to checkout head for all
\`bit checkout latest [component-pattern]\` => checkout to the latest satisfying semver tag, omit [component-pattern] to checkout latest for all
\`bit checkout reset [component-pattern]\` => remove local modifications from the specified ids (or all components when --all is used)`;
\`bit checkout <version> [component-pattern]\` => checkout the specified ids (or all components when --all is used) to the specified version
\`bit checkout head [component-pattern]\` => checkout to the last snap/tag (use --latest if you only want semver tags), omit [component-pattern] to checkout head for all
\`bit checkout latest [component-pattern]\` => checkout to the latest satisfying semver tag, omit [component-pattern] to checkout latest for all
\`bit checkout reset [component-pattern]\` => remove local modifications from the specified ids (or all components when --all is used)
when on a lane, "checkout head" only checks out components on this lane. to update main components, run "bit lane merge main"`;
alias = 'U';
options = [
[
Expand Down
13 changes: 9 additions & 4 deletions scopes/lanes/merge-lanes/merge-lane.cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,12 @@ Component pattern format: ${COMPONENT_PATTERN_HELP}`,
[
'',
'include-non-lane-comps',
'when merging main, include workspace components that are not on the lane (by default only lane components are merged)',
'DEPRECATED (this is now the default). when merging main, include workspace components that are not on the lane (by default only lane components are merged)',
],
[
'',
'exclude-non-lane-comps',
'when merging main into a lane, exclude workspace components that are not on the lane (by default all workspace components are merged)',
],
] as CommandOptions;
loader = true;
Expand Down Expand Up @@ -111,7 +116,7 @@ Component pattern format: ${COMPONENT_PATTERN_HELP}`,
resolveUnrelated,
ignoreConfigChanges,
verbose = false,
includeNonLaneComps = false,
excludeNonLaneComps = false,
}: {
ours?: boolean;
theirs?: boolean;
Expand All @@ -131,7 +136,7 @@ Component pattern format: ${COMPONENT_PATTERN_HELP}`,
resolveUnrelated?: string | boolean;
ignoreConfigChanges?: boolean;
verbose?: boolean;
includeNonLaneComps?: boolean;
excludeNonLaneComps?: boolean;
}
): Promise<string> {
build = (await this.globalConfig.getBool(CFG_FORCE_LOCAL_BUILD)) || Boolean(build);
Expand Down Expand Up @@ -183,7 +188,7 @@ Component pattern format: ${COMPONENT_PATTERN_HELP}`,
resolveUnrelated: getResolveUnrelated(),
ignoreConfigChanges,
includeDeps,
includeNonLaneComps,
excludeNonLaneComps,
});

const mergeResult = mergeReport({ ...mergeResults, configMergeResults, verbose });
Expand Down
8 changes: 4 additions & 4 deletions scopes/lanes/merge-lanes/merge-lanes.main.runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export type MergeLaneOptions = {
resolveUnrelated?: MergeStrategy;
ignoreConfigChanges?: boolean;
skipFetch?: boolean;
includeNonLaneComps?: boolean;
excludeNonLaneComps?: boolean;
};

export class MergeLanesMain {
Expand Down Expand Up @@ -97,7 +97,7 @@ export class MergeLanesMain {
resolveUnrelated,
ignoreConfigChanges,
skipFetch,
includeNonLaneComps,
excludeNonLaneComps,
} = options;

const currentLaneId = consumer.getCurrentLaneId();
Expand Down Expand Up @@ -139,7 +139,7 @@ export class MergeLanesMain {
const getBitIds = async () => {
if (isDefaultLane) {
if (!currentLane) throw new Error(`unable to merge ${DEFAULT_LANE}, the current lane was not found`);
return this.getMainIdsToMerge(currentLane, includeNonLaneComps);
return this.getMainIdsToMerge(currentLane, !excludeNonLaneComps);
}
if (!otherLane) throw new Error(`lane must be defined for non-default`);
return otherLane.toBitIds();
Expand Down Expand Up @@ -284,7 +284,7 @@ export class MergeLanesMain {
return { checkoutResults, restoredItems, checkoutError };
}

private async getMainIdsToMerge(lane: Lane, includeNonLaneComps = false) {
private async getMainIdsToMerge(lane: Lane, includeNonLaneComps: boolean) {
const laneIds = lane.toBitIds();
const ids = laneIds.filter((id) => this.scope.isExported(id));
if (includeNonLaneComps) {
Expand Down