feat: workflow merge compatibility#1075
Merged
josephjclark merged 7 commits intorelease/nextfrom Oct 24, 2025
Merged
Conversation
b10c2c1 to
d33ce05
Compare
packages/project/src/Workflow.ts
Outdated
| // return true if the current workflow can be merged into the target workflow without losing any changes | ||
| canMergeInto(target: Workflow) { | ||
| if (!target.history.length) return true; | ||
| const targetHead = target.history[target.history.length - 1]; |
Collaborator
There was a problem hiding this comment.
Open question: is the head the last history, or whatever the current actual version is?
Collaborator
|
TODO: add serialization of histories |
| t.true(sourceWf.canMergeInto(targetWf)); // allowed | ||
| }); | ||
|
|
||
| test('canMergeInto: empty target history', (t) => { |
Collaborator
There was a problem hiding this comment.
Yeah that's interesting
The target actually NEVER has an empty history - the head is just the current version (not the last history).
In this use-case, changes in the target (main) will be lost if they happen to not have been added to the source (staging). And because of this risk, canMergeInto should throw
This makes me think that using the current latest, not the history head, is actually what we wan
| this.workflow = clone(workflow); | ||
|
|
||
| // history needs to be on workflow object. | ||
| this.workflow.history = workflow.history?.length ? workflow.history : []; |
Collaborator
There was a problem hiding this comment.
this.workflow.history = workflow.history ?? []
josephjclark
approved these changes
Oct 24, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Short Description
Informs whether a workflow can be merged into a target workflow without losing any information/changes on target
Fixes #980
Implementation Details
Adds a method to the workflow class called
canMergeInto(target). Hence you pass the workflow you want to merge into as argument to the function which exist on another workflow(your source)A more detailed breakdown of the changes, including motivations (if not provided in the issue).
QA Notes
List any considerations/cases/advice for testing/QA here.
AI Usage
Please disclose how you've used AI in this work (it's cool, we just want to know!):
You can read more details in our Responsible AI Policy
Release branch checklist
Delete this section if this is not a release PR.
If this IS a release branch:
pnpm changeset versionfrom root to bump versionspnpm installpnpm changeset tagto generate tagsgit push --tagsTags may need updating if commits come in after the tags are first generated.