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(merge-from-scope), do not throw an error about missing artifacts when merging main to a lane #8557

Merged
merged 4 commits into from
Feb 22, 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
7 changes: 4 additions & 3 deletions scopes/lanes/merge-lanes/merge-lanes.main.runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,10 @@ export class MergeLanesMain {
// no need to export anything else other than the head. the normal calculation of what to export won't apply here
// as it is done from the scope.
exportHeadsOnly: shouldSquash,
// all artifacts must be pushed. they're all considered "external" in this case, because it's running from a
// bare-scope, but we don't want to ignore them, otherwise, they'll be missing from the component-scopes.
ignoreMissingExternalArtifacts: false,
// all artifacts must be pushed. otherwise, they'll be missing from the component-scopes.
// unless this is a merge from main to a lane, in which case it's not necessary to export the artifacts as
// the user importing them will get them from main.
throwForMissingArtifacts: !fromLaneId.isDefault(),
exportOrigin: 'lane-merge',
});
return exported;
Expand Down
9 changes: 3 additions & 6 deletions scopes/scope/export/export.main.runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,7 @@ if the export fails with missing objects/versions/components, run "bit fetch --l
originDirectly,
idsWithFutureScope,
resumeExportId,
ignoreMissingArtifacts,
ignoreMissingExternalArtifacts = true,
throwForMissingArtifacts,
isOnMain = true,
exportHeadsOnly, // relevant when exporting from bare-scope, especially when re-exporting existing versions, the normal calculation based on getDivergeData won't work
filterOutExistingVersions, // go to the remote and check whether the version exists there. if so, don't export it
Expand All @@ -248,8 +247,7 @@ if the export fails with missing objects/versions/components, run "bit fetch --l
originDirectly?: boolean;
idsWithFutureScope: ComponentIdList;
resumeExportId?: string | undefined;
ignoreMissingArtifacts?: boolean;
ignoreMissingExternalArtifacts?: boolean;
throwForMissingArtifacts?: boolean;
isOnMain?: boolean;
exportHeadsOnly?: boolean;
filterOutExistingVersions?: boolean;
Expand Down Expand Up @@ -419,8 +417,7 @@ if the export fails with missing objects/versions/components, run "bit fetch --l
const objectItems = await modelComponent.collectVersionsObjects(
scope.objects,
refs.map((ref) => ref.toString()),
ignoreMissingArtifacts,
ignoreMissingExternalArtifacts
throwForMissingArtifacts
);
const objectsList = await new ObjectList(objectItems).toBitObjects();
const componentAndObject = { component: modelComponent, objects: objectsList.getAll() };
Expand Down
11 changes: 5 additions & 6 deletions src/scope/models/model-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -796,8 +796,7 @@ export default class Component extends BitObject {
async collectVersionsObjects(
repo: Repository,
versions: string[],
ignoreMissingLocalArtifacts = false,
ignoreMissingExternalArtifacts = true
throwForMissingLocalArtifacts = false
): Promise<ObjectItem[]> {
const refsWithoutArtifacts: Ref[] = [];
const artifactsRefs: Ref[] = [];
Expand All @@ -816,7 +815,7 @@ export default class Component extends BitObject {
const refs = versionObject.refsWithOptions(false, false);
refsWithoutArtifacts.push(...refs);
const refsFromExtensions = getRefsFromExtensions(versionObject.extensions);
locallyChangedHashes.includes(versionObject.hash.toString()) || !ignoreMissingExternalArtifacts
locallyChangedHashes.includes(versionObject.hash().toString())
? artifactsRefs.push(...refsFromExtensions)
: artifactsRefsFromExportedVersions.push(...refsFromExtensions);
});
Expand All @@ -832,9 +831,9 @@ for a component "${this.id()}", versions: ${versions.join(', ')}`);
throw err;
}
try {
const loaded = ignoreMissingLocalArtifacts
? await repo.loadManyRawIgnoreMissing(artifactsRefs)
: await repo.loadManyRaw(artifactsRefs);
const loaded = throwForMissingLocalArtifacts
? await repo.loadManyRaw(artifactsRefs)
: await repo.loadManyRawIgnoreMissing(artifactsRefs);
loadedRefs.push(...loaded);
// ignore missing artifacts when exporting old versions that were exported in the past and are now exported to a
// different scope. this is happening for example when exporting a lane that has components from different
Expand Down