Skip to content

Commit 1bfe63a

Browse files
authored
auto-enable errors.json merge driver (#83420)
The merge driver for `errors.json` has been around for a while, and seems to work without issues. This PR enables it by default by installing it in `postinstall`(via the existing `git-configure.mjs` script which is invoked from there already) It also adds `scripts/merge-errors-json/uninstall` to temporarily disable it in case of issues. If the driver crashes, we'll also print instructions on how to disable it.
1 parent a225045 commit 1bfe63a

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

scripts/git-configure.mjs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1+
// @ts-check
12
import execa from 'execa'
23

34
// See https://github.com/vercel/next.js/pull/47375
4-
const { stdout, stderr } = await execa(
5-
'git',
6-
['config', 'index.skipHash', 'false'],
7-
{
8-
reject: false,
9-
}
10-
)
5+
await execa('git', ['config', 'index.skipHash', 'false'], {
6+
stdio: 'inherit',
7+
reject: false,
8+
})
119

12-
console.log(stderr + stdout)
10+
// Enable the errors.json git merge driver.
11+
// It can be disabled by running:
12+
//
13+
// scripts/merge-errors-json/uninstall
14+
//
15+
// or by manually removing the `[merge "errors-json"]` section from your .git/config.
16+
await execa('scripts/merge-errors-json/install', [], {
17+
stdio: 'inherit',
18+
reject: false,
19+
})

scripts/merge-errors-json/merge.mjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ function main() {
5050
process.exit(0)
5151
} catch (error) {
5252
console.error('merge-errors-json: merge failed:', error.message)
53+
console.error()
54+
console.error(
55+
[
56+
'if this error persists, you can disable the merge driver by running',
57+
'',
58+
' scripts/merge-errors-json/uninstall',
59+
'',
60+
'or by manually removing the `[merge "errors-json"]` section from your .git/config.',
61+
].join('\n')
62+
)
5363
process.exit(1)
5464
}
5565
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
driver_name='errors-json'
3+
git config --remove-section merge."$driver_name"

0 commit comments

Comments
 (0)