Git Komut Rehberi & Terminal Asistanı
Sıfırdan Yeni Bir Depo Başlatın:
Mevcut Bir Git Deposu veya Klasörü Gönderin:
Hataları Geri Alma, İptal & Temizlik:
Son commit'i geri al (yapılan değişiklikleri korur):
git reset --soft HEAD~1
Yapılan yerel değişiklikleri iptal et (çalışma ağacını temizler):
git restore .
Takip edilmeyen gereksiz dosyaları sil:
git clean -fd
Değişiklikleri geçici sakla ve geri getir (stash):
git stash git stash pop
Dal (Branch) ve Sürüm Etiketleri:
Yeni dal aç ve geçiş yap:
git checkout -b yeni-ozellik git push -u origin yeni-ozellik
Sürüm etiketi (tag) oluştur ve gönder:
git tag -a v1.0.0 -m "Sürüm 1.0.0" git push origin --tags
fix: keep grouped object IDs unique
This commit is contained in:
@@ -224,6 +224,31 @@ describe("SketchForge .skf project packages", () => {
|
||||
expect(restored.shapes[0].edgeTreatmentHistory?.[0].before.kind).toBe("box");
|
||||
});
|
||||
|
||||
it("repairs duplicate descendant IDs from legacy shallow-copied groups during export", async () => {
|
||||
const roof = shape("roundRoof", "round-roof-shared-child");
|
||||
const box = shape("box", "box-shared-child");
|
||||
const original = shape("mesh", "group-original", { groupedShapes: [roof, box] });
|
||||
const duplicate = { ...original, id: "group-copy", x: 30 };
|
||||
const history = [
|
||||
editorHistoryEntry([original], [original.id]),
|
||||
editorHistoryEntry([original, duplicate], [duplicate.id]),
|
||||
];
|
||||
|
||||
const exported = await exportSkfProject(input([original, duplicate], { history, historyIndex: 1 }));
|
||||
const restored = await importSkfProject(exported);
|
||||
const collectIds = (entry: WorkplaneShape): string[] => [
|
||||
entry.id,
|
||||
...(entry.groupedShapes ?? []).flatMap(collectIds),
|
||||
];
|
||||
const restoredIds = restored.shapes.flatMap(collectIds);
|
||||
|
||||
expect(original.groupedShapes?.[0].id).toBe(duplicate.groupedShapes?.[0].id);
|
||||
expect(restored.shapes.map((entry) => entry.id)).toEqual(["group-original", "group-copy"]);
|
||||
expect(new Set(restoredIds).size).toBe(restoredIds.length);
|
||||
expect(restored.history).toHaveLength(2);
|
||||
expect(restored.historyIndex).toBe(1);
|
||||
});
|
||||
|
||||
it("preserves every silently packaged undo and redo action", async () => {
|
||||
const created = shape("box", "history-box", { width: 20, depth: 20, x: 0 });
|
||||
const resized = { ...created, width: 30 };
|
||||
|
||||
@@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest";
|
||||
import type { WorkplaneShape } from "@/types/sketchforge";
|
||||
import {
|
||||
canonicalizeShape,
|
||||
cloneWorkplaneShapeTreeWithFreshIds,
|
||||
cleanNearZero,
|
||||
cleanRotationDegrees,
|
||||
fallbackSolidColor,
|
||||
@@ -98,6 +99,34 @@ describe("workplane shape helpers", () => {
|
||||
expect(canonical.groupedShapes?.[0].mirrorZ).toBeUndefined();
|
||||
});
|
||||
|
||||
it("assigns fresh object IDs throughout duplicated group trees", () => {
|
||||
const original = shape({
|
||||
id: "outer-group",
|
||||
kind: "mesh",
|
||||
groupedShapes: [
|
||||
shape({ id: "round-roof-child", kind: "roundRoof" }),
|
||||
shape({
|
||||
id: "nested-group",
|
||||
kind: "mesh",
|
||||
groupedShapes: [shape({ id: "nested-box" })],
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
const duplicate = cloneWorkplaneShapeTreeWithFreshIds(original, "copy");
|
||||
const collectIds = (entry: WorkplaneShape): string[] => [
|
||||
entry.id,
|
||||
...(entry.groupedShapes ?? []).flatMap(collectIds),
|
||||
];
|
||||
const originalIds = collectIds(original);
|
||||
const duplicateIds = collectIds(duplicate);
|
||||
|
||||
expect(new Set(duplicateIds).size).toBe(duplicateIds.length);
|
||||
expect(duplicateIds.every((id) => !originalIds.includes(id))).toBe(true);
|
||||
expect(original.groupedShapes?.[0].id).toBe("round-roof-child");
|
||||
expect(duplicate.groupedShapes?.[0].kind).toBe("roundRoof");
|
||||
});
|
||||
|
||||
it("keeps shallow equality strict for shape payload references", () => {
|
||||
const importedMesh = { positions: [0, 0, 0], baseWidth: 1, baseDepth: 1, baseHeight: 1, triangleCount: 0, sourceFormat: "json" as const };
|
||||
const first = shape({ importedMesh });
|
||||
|
||||
Reference in New Issue
Block a user