Skip to content

Commit 89edf83

Browse files
committed
generate: rebase module changesets onto a common base
Each module's changeset is taken against its own dependency-staged workspace, so sibling changesets disagree on their befores. Merging them unions the bases: one module's staged dep codegen (e.g. engine-dev regenerated as release's dep) leaks into the merge base, and the owning module's own patch then re-applies the same insertions at an offset, duplicating generated code. Rebase every changeset onto the unstaged workspace at the caller cwd before merging so they share a base.
1 parent 0c04581 commit 89edf83

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

‎go-sdk.dang‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,9 @@ type GoSdk {
341341
"""
342342
generate(ws: Workspace!): Changeset! @generate {
343343
let pws = polyfill.workspace(ws)
344+
# Shared rebase base: the unstaged workspace at the caller cwd. Module
345+
# changesets are cwd-relative, so their paths resolve against this root.
346+
let base = ws.directory(".")
344347
changeset.withChangesets(
345348
modules(ws)
346349
.filter { !_.skipGenerate(ws) }
@@ -352,7 +355,16 @@ type GoSdk {
352355
let stagedWs = ws.withChanges(
353356
pws.moduleSource("/" + mod.rootPath).core.generateLocalDependencies(ws),
354357
)
355-
polyfill.workspace(stagedWs).moduleSource("/" + mod.rootPath).generate
358+
# Rebase the module's changeset onto the shared unstaged base. Each
359+
# changeset's before is its own differently-staged workspace, and
360+
# merging changesets whose befores disagree unions the bases: one
361+
# module's staged dependency codegen (e.g. engine-dev regenerated as
362+
# release's dep) leaks into the merge base, and the owning module's
363+
# own patch then re-applies the same insertions at an offset,
364+
# duplicating generated code.
365+
base.withChanges(
366+
polyfill.workspace(stagedWs).moduleSource("/" + mod.rootPath).generate,
367+
).changes(base)
356368
},
357369
)
358370
}

‎mod.dang‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,13 @@ type Mod {
6767
let stagedWs = ws.withChanges(
6868
polyfill.workspace(ws).moduleSource("/" + rootPath).core.generateLocalDependencies(ws),
6969
)
70-
polyfill.workspace(stagedWs).moduleSource("/" + rootPath).generate
70+
# Rebase the changeset onto the unstaged workspace so callers merging it
71+
# with sibling changesets see a common base rather than this module's
72+
# staged dependency codegen (see GoSdk.generate).
73+
let base = ws.directory(".")
74+
base.withChanges(
75+
polyfill.workspace(stagedWs).moduleSource("/" + rootPath).generate,
76+
).changes(base)
7177
}
7278
}
7379
}

0 commit comments

Comments
 (0)