Skip to content

Commit 613d9e4

Browse files
authored
Merge pull request #43 from brave/revert-37-split-patches
Revert "Split patches"
2 parents 3fdf2ab + 314a290 commit 613d9e4

File tree

1 file changed

+3
-48
lines changed

1 file changed

+3
-48
lines changed

lib/updatePatches.js

+3-48
Original file line numberDiff line numberDiff line change
@@ -6,54 +6,9 @@ const util = require('../lib/util')
66
const updatePatches = (options) => {
77
config.update(options)
88

9-
const runOptions = { cwd: config.projects.chrome.dir }
10-
const patchDir = path.join(config.projects.antimuon.dir, 'patches')
11-
12-
console.log('updatePatches writing files to: ' + patchDir)
13-
14-
// grab Modified (and later Deleted) files but not Created (since we copy those)
15-
const modifiedDiffArgs = ['diff', '--diff-filter=M', '--name-only', '--ignore-space-at-eol']
16-
let modifiedDiff = util.run('git', modifiedDiffArgs, runOptions)
17-
let moddedFileList = modifiedDiff.stdout.toString().split('\n').filter(s => s.length > 0)
18-
19-
let n = moddedFileList.length
20-
21-
// When splitting one large diff into a per-file diff, there are a few ways
22-
// you can go about it. Because different files can have the same name
23-
// (by being located in different directories), you need to avoid collisions.
24-
// Mirroring the directory structure seems undesirable.
25-
// Prefixing with numbers works but is O(n) volatile for O(1) additions
26-
// We choose here to flatten the directory structure by replacing separators
27-
// In practice this will avoid collisions. Should a pathological case ever
28-
// appear, you can quickly patch this by changing the separator, even
29-
// to something longer
30-
31-
const desiredReplacementSeparator = '-'
32-
const patchExtension = '.patch'
33-
34-
for (var i = 0; i < n; i++) {
35-
const old = moddedFileList[i]
36-
let revised = old
37-
38-
//replacing forward slashes
39-
//since git on Windows doesn't use backslashes, this is sufficient
40-
revised = revised.replace(/\//g, desiredReplacementSeparator)
41-
42-
const singleDiffArgs = ['diff', '--src-prefix=a/', '--dst-prefix=b/', '--full-index', old]
43-
let singleDiff = util.run('git', singleDiffArgs, runOptions)
44-
45-
const contents = singleDiff.stdout.toString()
46-
const filename = revised + patchExtension
47-
48-
fs.writeFileSync(path.join(patchDir, filename), contents)
49-
50-
console.log('updatePatches wrote ' + (1 + i) + '/' + n + ': ' + filename)
51-
}
52-
53-
// finish off by creating one big patch for deleted files
54-
const deletedDiffArgs = ['diff', '--diff-filter=D', '--src-prefix=a/', '--dst-prefix=b/', '--full-index', '--ignore-space-at-eol']
55-
let deletedDiff = util.run('git', deletedDiffArgs, runOptions)
56-
fs.writeFileSync(path.join(patchDir, 'master_deleted_patch.patch'), deletedDiff.stdout)
9+
const diffArgs = ['diff', '--full-index', '--ignore-space-at-eol']
10+
let diff = util.run('git', diffArgs, { cwd: config.projects.chrome.dir })
11+
fs.writeFileSync(path.join(config.projects.antimuon.dir, 'patches', 'master_patch.patch'), diff.stdout)
5712
}
5813

5914
module.exports = updatePatches

0 commit comments

Comments
 (0)