Commit e89449c
committed
resolves #4135 ([FR-1365](https://lablup.atlassian.net/browse/FR-1365))
### Add JSON merge driver for better conflict resolution
Enhanced the i18n JSON merge driver to automatically resolve conflicts during Git merges and added a comprehensive test suite to ensure reliability.
### Driver Settings
Even if `.gitconfig` is included in the remote branch, it may not be applied due to security concerns. Save the contents of `.gitconfig` as-is, then verify that the json-i18n driver is configured for the i18n file using the command `git check-attr merge <i18n-json-path>`.
- `git config --local include.path ../.gitconfig`
### Changes
1. Merge Driver Improvements
(`scripts/i18n-merge-driver.js`)
- **Added key sorting priority**: Ensures
`$schema` key always appears at the top of
JSON objects
- **Consistent key ordering**: Applied
stable sorting (lowercase → uppercase →
special characters)
- **Fixed Git configuration**: Corrected
merge driver setup to match
`.gitattributes`
(`merge.json-i18n.driver`)
### Merge Case Scenarios
✅ Automatically Successful Cases
1. **Different keys modified**
```json
// Base: {"key1": "value1"}
// Ours: {"key1": "value1", "newKey": "ours"}
// Theirs: {"key1": "value1", "anotherKey": "theirs"}
// → Auto-merge successful
2. Same key modified identically
```json
// Base: {"key1": "old"}
// Ours: {"key1": "new"}
// Theirs: {"key1": "new"}
// → Auto-merge successful
3. One-sided modifications
```json
// Base: {"key1": "value1", "key2": "value2"}
// Ours: {"key1": "modified", "key2": "value2"}
// Theirs: {"key1": "value1", "key2": "value2"}
// → Auto-merge successful
4. Key addition/deletion combinations
```json
// Base: {"key1": "value1", "toDelete": "will be removed"}
// Ours: {"key1": "value1"} // Key deleted
// Theirs: {"key1": "value1", "toDelete": "will be removed", "newKey": "added"}
// → Auto-merge successful
❌ Conflict Cases
1. Same key modified differently
```json
// Base: {"key1": "original"}
// Ours: {"key1": "changed by ours"}
// Theirs: {"key1": "changed by theirs"}
// → Conflict occurs, manual resolution required
2. Nested object conflicts
```json
// Base: {"comp:Button": {"label": "Click"}}
// Ours: {"comp:Button": {"label": "클릭"}}
// Theirs: {"comp:Button": {"label": "Press"}}
// → Conflict occurs, manual resolution required
3. Mixed scenarios (partial success, partial conflict)
```json
// Base: {"safe": "value", "conflict": "original"}
// Ours: {"safe": "value", "conflict": "ours", "newKey": "added"}
// Theirs: {"safe": "value", "conflict": "theirs", "anotherKey": "added"}
// → Conflict occurs (due to conflict key), entire merge fails
This enhancement enables automatic handling of most i18n JSON file merge conflicts while providing test coverage to ensure stability across complex scenarios.
**Checklist:** (if applicable)
- [ ] Documentation
- [ ] Minium required manager version
- [ ] Specific setting for review (eg., KB link, endpoint or how to setup)
- [ ] Minimum requirements to check during review
- [ ] Test case(s) to demonstrate the difference of before/after
[FR-1365]: https://lablup.atlassian.net/browse/FR-1365?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
1 parent f1d6778 commit e89449c
File tree
5 files changed
+484
-1
lines changed- scripts
5 files changed
+484
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
231 | | - | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
232 | 236 | | |
233 | 237 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
0 commit comments