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(checkout), enable checking out main-ids where on a lane #9440

Merged
merged 1 commit into from
Jan 10, 2025
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
15 changes: 15 additions & 0 deletions e2e/harmony/checkout-harmony.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -680,4 +680,19 @@ describe('bit checkout command', function () {
expect(() => helper.command.status()).to.not.throw();
});
});
describe('checkout main component when on a lane', () => {
before(() => {
helper.scopeHelper.setNewLocalAndRemoteScopes();
helper.fixtures.populateComponents(1);
helper.command.tagAllWithoutBuild();
helper.command.tagAllWithoutBuild('--unmodified');
helper.command.export();
helper.command.createLane('dev');
helper.command.checkoutVersion('0.0.1', 'comp1', '-x');
});
it('should checkout the component successfully', () => {
const bitmap = helper.bitMap.read();
expect(bitmap.comp1.version).to.equal('0.0.1');
});
});
});
7 changes: 6 additions & 1 deletion scopes/component/checkout/checkout.main.runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,12 @@ export class CheckoutMain {

const currentLane = await this.workspace.consumer.getCurrentLaneObject();
const currentLaneIds = currentLane?.toComponentIds();
const ids = currentLaneIds ? idsOnWorkspace.filter((id) => currentLaneIds.hasWithoutVersion(id)) : idsOnWorkspace;
// when no ids were given and the user is on a lane, return lane-ids only.
// it's relevant for cases like "bit checkout head" when on a lane to not checkout main components. (see https://github.com/teambit/bit/pull/6853)
const ids =
currentLaneIds && !componentPattern
? idsOnWorkspace.filter((id) => currentLaneIds.hasWithoutVersion(id))
: idsOnWorkspace;
checkoutProps.ids = ids.map((id) => (checkoutProps.head || checkoutProps.latest ? id.changeVersion(LATEST) : id));
}

Expand Down