Skip to content

Commit 79c8465

Browse files
authored
Force merge by default (#1095)
* force merge by default In the CLI, we only force merge when the user asks us to. But here in project, we prefer to force merge. If you ask to merge two projects, we just merge them. Why woulldn't we? Add safeguads in the application, not down in the API If it feels like a strange default its because the CLI should be doing all the force stuff, not the Project, but there we go * force where needed * update integration test
1 parent b61bf9b commit 79c8465

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

integration-tests/cli/test/project.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,14 @@ test.serial('merge a project', async (t) => {
152152
'utf8'
153153
).then((str) => str.trim());
154154

155-
// assert the intial step code
155+
// assert the initial step code
156156
const initial = await readStep();
157157
t.is(initial, '// TODO');
158158

159159
// Run the merge
160-
await run(`openfn merge hello-world-staging -p ${projectsPath}`);
160+
const { stdout } = await run(
161+
`openfn merge hello-world-staging -p ${projectsPath} --force`
162+
);
161163

162164
// Check the step is updated
163165
const merged = await readStep();

packages/cli/src/merge/handler.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ const mergeHandler = async (options: MergeOptions, logger: Logger) => {
5151
return;
5252
}
5353

54-
// TODO pick options from the terminal
5554
const final = Project.merge(sourceProject, targetProject, {
5655
removeUnmapped: options.removeUnmapped,
5756
workflowMappings: options.workflowMappings,

packages/project/src/merge/merge-project.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export function merge(
3131
const defaultOptions: MergeProjectOptions = {
3232
workflowMappings: {},
3333
removeUnmapped: false,
34+
force: true,
3435
};
3536
options = defaultsDeep<MergeProjectOptions>(options, defaultOptions);
3637

packages/project/test/project.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,12 @@ test('incompatible-merge: should throw error when merge is incompatible', (t) =>
165165

166166
const sourceProject = new Project({ workflows: [source] });
167167
const targetProject = new Project({ workflows: [target] });
168-
t.throws(() => Project.merge(sourceProject, targetProject), {
169-
message: `The below workflows can't be merged directly without losing data\nWorkflow → Workflow\nPass --force to force the merge anyway`,
170-
});
168+
t.throws(
169+
() => Project.merge(sourceProject, targetProject, { force: false }),
170+
{
171+
message: `The below workflows can't be merged directly without losing data\nWorkflow → Workflow\nPass --force to force the merge anyway`,
172+
}
173+
);
171174
});
172175

173176
test('incompatible-merge-force: should ignore incompatiblity and merge when forced', (t) => {

0 commit comments

Comments
 (0)