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: issue-5850 - Settle override conflicts between edges and propagate changes #7025

Open
wants to merge 33 commits into
base: latest
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
865070c
Settle overrides conflicts between edges, and propagate changes to th…
AlonNavon Nov 23, 2023
cd20196
cleanup
AlonNavon Nov 26, 2023
0cad4e0
Optimization
AlonNavon Nov 26, 2023
6b276f3
Fix override sets comparisons
AlonNavon Nov 28, 2023
fff3072
Add comparator
AlonNavon Nov 28, 2023
e97176e
Check for undefined
AlonNavon Nov 28, 2023
19155ed
Another place
AlonNavon Nov 28, 2023
dedbccf
Fix
AlonNavon Nov 28, 2023
4a83786
Lint fixes
AlonNavon Dec 6, 2023
7ee2f2e
Added tests
AlonNavon Dec 6, 2023
0917421
Overrides aren't inherited from parent, but from to nodes
AlonNavon Oct 27, 2024
6d0ad42
Always use raw spec when analyzing overrides
AlonNavon Oct 28, 2024
67d7d5c
Replaceability
AlonNavon Oct 28, 2024
643cbea
Overridden status
AlonNavon Oct 28, 2024
c5f6e4a
Fix undefined bugs
AlonNavon Oct 28, 2024
6c9bbf9
Parent doesn't matter to overrides
AlonNavon Oct 28, 2024
63760d9
Update override set in reload
AlonNavon Oct 28, 2024
6111630
Erroneous node
AlonNavon Oct 28, 2024
b42d4c8
Add comments
AlonNavon Oct 29, 2024
7d97726
Code review fixes
AlonNavon Nov 4, 2024
35e5790
Fix edge satisfaction logic
AlonNavon Nov 4, 2024
35ce2f7
Fix dedupe logic
AlonNavon Nov 4, 2024
5630954
Code review fixes
AlonNavon Nov 4, 2024
f859e92
Oops
AlonNavon Nov 4, 2024
29f0750
Static function
AlonNavon Nov 5, 2024
17ec457
Typo
AlonNavon Nov 5, 2024
4cde831
Shouldn't throw
AlonNavon Nov 7, 2024
701b125
CR fixes
AlonNavon Nov 7, 2024
b119f67
CR fixes
AlonNavon Nov 7, 2024
3136b64
Move functions
AlonNavon Nov 10, 2024
80126c7
Comments
AlonNavon Nov 11, 2024
c4b5338
Override sets unit tests
AlonNavon Nov 11, 2024
9db1232
Clarify comment
AlonNavon Nov 11, 2024
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
117 changes: 117 additions & 0 deletions workspaces/arborist/test/override-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,4 +271,121 @@ t.test('constructor', async (t) => {
const outOfRangeRule = bazEdgeRule.getEdgeRule({ name: 'buzz', spec: 'github:baz/buzz#semver:^2.0.0' })
t.equal(outOfRangeRule.name, 'baz', 'no match - returned parent')
})

t.test('isequal and findspecificoverrideset tests', async (t) => {
AlonNavon marked this conversation as resolved.
Show resolved Hide resolved
const overrides1 = new OverrideSet({
overrides: {
foo: {
bar: {
'.': '2.0.0',
baz: '3.0.0',
},
baz: '2.0.0',
},
bar: '1.0.0',
baz: '1.0.0',
},
})
const overrides2 = new OverrideSet({
overrides: {
foo: {
bar: {
'.': '2.0.0',
baz: '3.0.0',
},
baz: '2.0.0',
},
bar: '1.0.0',
baz: '1.0.0',
},
})
const overrides3 = new OverrideSet({
overrides: {
foo: {
bar: {
'.': '2.0.0',
baz: '3.1.0',
},
baz: '2.0.0',
},
bar: '1.0.0',
baz: '1.0.0',
},
})
const overrides4 = new OverrideSet({
overrides: {
foo: {
bar: {
'.': '2.0.0',
},
baz: '2.0.0',
},
bar: '1.0.0',
baz: '1.0.0',
},
})
const overrides5 = new OverrideSet({
overrides: {
foo: {
bar: {
'.': '2.0.0',
},
bat: '2.0.0',
},
bar: '1.0.0',
baz: '1.0.0',
},
})
const overrides6 = new OverrideSet({
overrides: {
bar: {
'.': '2.0.0',
},
bat: '2.0.0',
},
})
const overrides7 = new OverrideSet({
overrides: {
bat: '2.0.0',
},
})
const overrides8 = new OverrideSet({
overrides: {
bat: '1.2.0',
},
})
const overrides9 = new OverrideSet({
overrides: {
'bat@3.0.0': '1.2.0',
},
})

t.ok(overrides1.isEqual(overrides1), 'override set is equal to itself')
t.ok(overrides1.isEqual(overrides2), 'two identical override sets are equal')
t.ok(!overrides1.isEqual(overrides3), 'two different override sets are not equal')
t.ok(!overrides2.isEqual(overrides3), 'two different override sets are not equal')
t.ok(!overrides3.isEqual(overrides1), 'two different override sets are not equal')
t.ok(!overrides3.isEqual(overrides2), 'two different override sets are not equal')
t.ok(!overrides4.isEqual(overrides1), 'two different override sets are not equal')
t.ok(!overrides4.isEqual(overrides2), 'two different override sets are not equal')
t.ok(!overrides4.isEqual(overrides3), 'two different override sets are not equal')
t.ok(!overrides4.isEqual(overrides5), 'two override sets that differ only by package name are not equal')
t.ok(!overrides5.isEqual(overrides4), 'two override sets that differ only by package name are not equal')
t.equal(OverrideSet.findSpecificOverrideSet(overrides5, overrides5), overrides5, "find more specific override set when the sets are identical")
t.equal(OverrideSet.findSpecificOverrideSet(overrides5, overrides6), overrides6, "find more specific override set when it's the second")
t.equal(OverrideSet.findSpecificOverrideSet(overrides6, overrides5), overrides6, "find more specific override set when it's the first")
t.ok(!OverrideSet.doOverrideSetsConflict(overrides1, overrides2), "override sets are equal")
t.ok(!OverrideSet.doOverrideSetsConflict(overrides5, overrides5), "override sets are the same object")
t.ok(!OverrideSet.doOverrideSetsConflict(overrides5, overrides6), "one override set is the specific version of the other")
t.ok(!OverrideSet.doOverrideSetsConflict(overrides6, overrides5), "one override set is the specific version of the other")
t.ok(OverrideSet.doOverrideSetsConflict(overrides5, overrides7), "no override set is the specific version of the other")
t.ok(OverrideSet.doOverrideSetsConflict(overrides7, overrides5), "no override set is the specific version of the other")
t.ok(!overrides7.isEqual(overrides8), 'two override sets that differ in the version are not equal')
t.ok(!overrides8.isEqual(overrides9), 'two override sets that differ in the range are not equal')
t.ok(!overrides7.isEqual(overrides9), 'two override sets that differ in both version and range are not equal')
t.ok(OverrideSet.doOverrideSetsConflict(overrides7, overrides8), "override sets are incomparable due to version")
t.ok(OverrideSet.doOverrideSetsConflict(overrides7, overrides9), "override sets are incomparable due to version and range")
t.ok(OverrideSet.doOverrideSetsConflict(overrides8, overrides9), "override sets are incomparable due to range")

})
})