planning
All checks were successful
Publish To Prod / deploy_and_publish (push) Successful in 35s

This commit is contained in:
2024-10-14 09:15:30 +02:00
parent bcba00a730
commit 6e64e138e2
21059 changed files with 2317811 additions and 1 deletions

22
node_modules/what-the-diff/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,22 @@
Copyright (c) 2016 Katrina Uychaco
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

57
node_modules/what-the-diff/README.md generated vendored Normal file
View File

@@ -0,0 +1,57 @@
# JavaScript Diff Parser
![](https://pbs.twimg.com/media/ByZVWXgIIAA5Y2D.png:large)
Credit: [@eightballart](https://twitter.com/EightballArt/status/515195030546690048)
Parse unified diffs with JavaScript
## Installation
what-the-diff is available via npm
npm install what-the-diff
## Usage
```javascript
let {parse} = require('what-the-diff')
var str = `diff --git file.txt file.txt
index 83db48f..bf269f4 100644
--- file.txt
+++ file.txt
@@ -1,3 +1,3 @@
line1
-line2
+new line
line3`
parse(diffStr)
// returns
{
oldPath: 'file.txt',
newPath: 'file.txt',
oldMode: '100644',
newMode: '100644',
status: 'modified',
hunks: [
{
oldStartLine: 1,
oldLineCount: 3,
newStartLine: 1,
newLineCount: 3,
lines: [
' line1',
'-line2',
'+new line',
' line3'
]
}
]
}
```
If the diff includes a similarity index line (from a detected copy or rename), the `similarity` property will be set, and will be a number.

7
node_modules/what-the-diff/index.js generated vendored Normal file
View File

@@ -0,0 +1,7 @@
var parser = require('./lib/parser')
module.exports = {
parse: function(input) {
return parser.parse(input.toString())
}
}

1
node_modules/what-the-diff/lib/.gitkeep generated vendored Normal file
View File

@@ -0,0 +1 @@
!.

2322
node_modules/what-the-diff/lib/parser.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

29
node_modules/what-the-diff/package.json generated vendored Normal file
View File

@@ -0,0 +1,29 @@
{
"name": "what-the-diff",
"version": "0.6.0",
"description": "diff parsing library",
"main": "index.js",
"scripts": {
"build": "pegjs --cache -o lib/parser.js src/diff.pegjs",
"test": "nodeunit test/*.test.js",
"prepublish": "npm run build"
},
"repository": "git://github.com/kuychaco/what-the-diff.git",
"keywords": [
"diff",
"parser"
],
"files": [
"index.js",
"lib/**/*",
"src/**/*",
"test/**/*"
],
"author": "Katrina Uychaco <kuychaco@gmail.com>",
"license": "MIT",
"devDependencies": {
"dedent-js": "^1.0.1",
"nodeunit": "^0.10.2",
"pegjs": "^0.10.0"
}
}

192
node_modules/what-the-diff/src/diff.pegjs generated vendored Normal file
View File

@@ -0,0 +1,192 @@
{
function postProcessDiff (header, file_modes, patch, binary) {
let status
if (file_modes.old_mode && !file_modes.new_mode) {
return {
newPath: null,
oldPath: header.file_name,
newMode: null,
oldMode: file_modes.old_mode,
hunks: patch ? patch.hunks : [],
status: 'deleted',
binary: !!binary
}
} else if (!file_modes.old_mode && file_modes.new_mode) {
return {
oldPath: null,
newPath: header.file_name,
oldMode: null,
newMode: file_modes.new_mode,
hunks: patch ? patch.hunks : [],
status: 'added',
binary: !!binary
}
} else if (file_modes.old_mode && file_modes.new_mode) {
return {
newPath: header.file_name,
oldPath: header.file_name,
oldMode: file_modes.old_mode,
newMode: file_modes.new_mode,
hunks: patch ? patch.hunks : [],
status: 'modified',
binary: !!binary
}
} else {
throw new Error('file modes missing')
}
}
function postProcessMergeConflictDiff (filePath, patch, binary) {
patch = patch || {}
patch.filePath = filePath
patch.status = 'unmerged'
patch.binary = !!binary
return patch
}
function postProcessSimilarityDiff (rename_or_copy, similarity_index, old_file, new_file, file_modes, patch) {
const diff = {
oldPath: old_file,
newPath: new_file,
hunks: patch ? patch.hunks : [],
status: rename_or_copy === 'copy' ? 'copied' : 'renamed',
similarity: similarity_index,
}
if (file_modes) {
diff.oldMode = file_modes.old_mode
diff.newMode = file_modes.new_mode
}
return diff
}
}
diffs
= diffs:diff* { return diffs }
diff
= binary_merge_conflict_diff
/ rename_or_copy_diff
/ merge_conflict_diff
/ unmerged_path
/ binary_diff
/ regular_diff
binary_diff
= header:diff_header_line file_modes:file_mode_section? patch_header? binary_declaration { return postProcessDiff(header, file_modes, undefined, true) }
binary_declaration
= 'Binary files ' TEXT NL
regular_diff
= header:diff_header_line file_modes:file_mode_section? patch:patch? { return postProcessDiff(header, file_modes, patch) }
binary_merge_conflict_diff
= path:merge_conflict_header_line index_line binary_declaration { return postProcessMergeConflictDiff(path, undefined, true) }
rename_or_copy_diff
= rename_or_copy_diff_header_line modes:changed_file_modes? similarity:similarity_index copy_from:rename_copy_from copy_to:rename_copy_to
index_modes:index_line? patch:(binary_declaration / patch)?
{
return postProcessSimilarityDiff(copy_from.operation, similarity, copy_from.file, copy_to.file, modes || index_modes, patch)
}
merge_conflict_diff
= path:merge_conflict_header_line index_line patch:patch? { return postProcessMergeConflictDiff(path, patch) }
merge_conflict_header_line
= 'diff --cc ' path:TEXT NL { return path }
unmerged_path
= '* Unmerged path ' path:TEXT NL { return postProcessMergeConflictDiff(path) }
patch
= header:patch_header hunks:hunk* { return {hunks} }
patch_header
= '--- ' old_file_name:TEXT NL '+++ ' new_file_name:TEXT NL { return {old_file_name, new_file_name} }
hunk
= header:hunk_header lines:hunk_line+ {
return Object.assign({}, header, {
lines: lines
})
}
hunk_header
= merge_conflict_hunk_header
/ regular_hunk_header
merge_conflict_hunk_header
= '@@@ -' our_range:hunk_range ' -' base_range:hunk_range ' +' their_range:hunk_range ' @@@' context:TEXT? NL {
return {
ourStartLine: our_range.start,
ourLineCount: our_range.count,
theirStartLine: their_range.start,
theirLineCount: their_range.count,
baseStartLine: base_range.start,
baseLineCount: base_range.count,
heading: context ? context.trim() : '',
}
}
regular_hunk_header
= '@@ -' old_range:hunk_range ' +' new_range:hunk_range ' @@' context:TEXT? NL {
return {
oldStartLine: old_range.start,
oldLineCount: old_range.count,
newStartLine: new_range.start,
newLineCount: new_range.count,
heading: context ? context.trim() : '',
}
}
hunk_range
= start:NUMBER ',' count:NUMBER { return {start, count} }
/ start:NUMBER { return {start, count: 1} }
hunk_line
= chars:(('+' / '-' / ' ' / '\\') TEXT?) NL { return chars.join('') }
diff_header_line
= 'diff ' options:TEXT_NO_SPACES ' ' file_name:file_name_str NL { return {file_name} }
rename_or_copy_diff_header_line
= 'diff ' options:TEXT_NO_SPACES ' ' files_unused:TEXT NL
file_name_str
= str:TEXT { return str.substr(str.length/2 + 1) }
similarity_index
= 'similarity index ' idx:NUMBER '%' NL { return idx }
file_mode_section
= explicit_file_modes:(new_or_deleted_file_mode / changed_file_modes)? index_file_modes:index_line? { return explicit_file_modes || index_file_modes }
new_or_deleted_file_mode
= type:('new'/'deleted') ' file mode ' file_mode:TEXT NL {
if (type === 'new') return {old_mode: null, new_mode: file_mode}
else return {old_mode: file_mode, new_mode: null}
}
changed_file_modes
= 'old mode ' old_mode:TEXT NL 'new mode ' new_mode:TEXT NL { return {old_mode, new_mode} }
rename_copy_from
= operation:('rename' / 'copy') ' from ' file:TEXT NL { return {operation, file} }
rename_copy_to
= operation:('rename' / 'copy') ' to ' file:TEXT NL { return {operation, file} }
index_line
= 'index ' TEXT_NO_SPACES ' ' file_mode:TEXT NL { return {old_mode: file_mode, new_mode: file_mode} }
/ 'index ' TEXT_NO_SPACES NL
S = [ \t]
NL = ("\n" / "\r\n") / EOF
NLS = NL / S
EOF = !.
TEXT = chars:[^\r\n]+ { return chars.join('') }
TEXT_NO_SPACES = chars:[^ \t\r\n]+ { return chars.join('') }
NUMBER = chars:[0-9]+ { return parseInt(chars.join(''), 10) }

674
node_modules/what-the-diff/test/diff.test.js generated vendored Normal file
View File

@@ -0,0 +1,674 @@
var diff = require('../')
var dedent = require('dedent-js')
var fs = require('fs')
var assert = require("nodeunit").assert
exports.testSimplePatch = function(test) {
var str = dedent`
diff --git file.txt file.txt
index 83db48f..bf269f4 100644
--- file.txt
+++ file.txt
@@ -1,3 +1,3 @@ class Thing {
line1
-line2
+new line
line3
`
const output = diff.parse(str)
assert.deepEqual(output, [
{
oldPath: 'file.txt',
newPath: 'file.txt',
oldMode: '100644',
newMode: '100644',
status: 'modified',
hunks: [
{
oldStartLine: 1,
oldLineCount: 3,
newStartLine: 1,
newLineCount: 3,
heading: 'class Thing {',
lines: [
' line1',
'-line2',
'+new line',
' line3'
]
}
],
binary: false
}
])
test.done()
}
exports.testNewPatch = function(test) {
var str = dedent`
diff --git file.txt file.txt
new file mode 100644
index 0000000..dab621c
--- /dev/null
+++ file.txt
@@ -0,0 +1 @@
+foo
`
const output = diff.parse(str)
assert.deepEqual(output, [
{
oldPath: null,
newPath: 'file.txt',
oldMode: null,
newMode: '100644',
status: 'added',
hunks: [
{
oldStartLine: 0,
oldLineCount: 0,
newStartLine: 1,
newLineCount: 1,
heading: '',
lines: ['+foo']
}
],
binary: false
}
])
test.done()
}
exports.testRemovedPatch = function(test) {
var str = dedent`
diff --git file.txt file.txt
deleted file mode 100644
index dab621c..0000000
--- file.txt
+++ /dev/null
@@ -1 +0,0 @@
-foo
`
const output = diff.parse(str)
assert.deepEqual(output, [
{
oldPath: 'file.txt',
newPath: null,
oldMode: '100644',
newMode: null,
status: 'deleted',
hunks: [
{
oldStartLine: 1,
oldLineCount: 1,
newStartLine: 0,
newLineCount: 0,
heading: '',
lines: ['-foo']
}
],
binary: false
}
])
test.done()
}
exports.testFileModeChange = function(test) {
var str = dedent`
diff --git file.txt file.txt
old mode 100644
new mode 100755
index 83db48f..bf269f4
--- file.txt
+++ file.txt
@@ -1,3 +1,3 @@
line1
-line2
+new line
line3
`
const output = diff.parse(str)
assert.deepEqual(output, [
{
oldPath: 'file.txt',
newPath: 'file.txt',
oldMode: '100644',
newMode: '100755',
status: 'modified',
hunks: [
{
oldStartLine: 1,
oldLineCount: 3,
newStartLine: 1,
newLineCount: 3,
heading: '',
lines: [
' line1',
'-line2',
'+new line',
' line3'
]
}
],
binary: false
}
])
test.done()
}
exports.testNewEmptyFile = function(test) {
var str = dedent`
diff --git newfile.txt newfile.txt
new file mode 100644
index 0000000..e69de29
`
const output = diff.parse(str)
assert.deepEqual(output, [
{
oldPath: null,
newPath: 'newfile.txt',
oldMode: null,
newMode: '100644',
hunks: [],
status: 'added',
binary: false
}
])
test.done()
}
exports.testSingleLineHunk = function(test) {
var str = dedent`
diff --git file.txt file.txt
index 83db48f..bf269f4 100644
--- file.txt
+++ file.txt
@@ -1 +1 @@
-line1
+line2
`
const output = diff.parse(str)
assert.deepEqual(output, [
{
oldPath: 'file.txt',
newPath: 'file.txt',
oldMode: '100644',
newMode: '100644',
status: 'modified',
hunks: [
{
oldStartLine: 1,
oldLineCount: 1,
newStartLine: 1,
newLineCount: 1,
heading: '',
lines: [
'-line1',
'+line2'
]
}
],
binary: false
}
])
test.done()
}
exports.testMultipleHunks = function(test) {
var str = dedent`
diff --git file.txt file.txt
index 83db48f..bf269f4 100644
--- file.txt
+++ file.txt
@@ -1,5 +1,4 @@
line1
-line2
line3
line4
line5
@@ -15,4 +14,5 @@
line6
line7
line8
+line2
line9
`
const output = diff.parse(str)
assert.deepEqual(output, [
{
oldPath: 'file.txt',
newPath: 'file.txt',
oldMode: '100644',
newMode: '100644',
status: 'modified',
hunks: [
{
oldStartLine: 1,
oldLineCount: 5,
newStartLine: 1,
newLineCount: 4,
heading: '',
lines: [
' line1',
'-line2',
' line3',
' line4',
' line5'
]
},
{
oldStartLine: 15,
oldLineCount: 4,
newStartLine: 14,
newLineCount: 5,
heading: '',
lines: [
' line6',
' line7',
' line8',
'+line2',
' line9'
]
}
],
binary: false
}
])
test.done()
}
exports.testRemovedEOFNL = function(test) {
var str = dedent`
diff --git file.txt file.txt
index a999a0c..266014b 100644
--- file.txt
+++ file.txt
@@ -1 +1 @@
-line
+line
\ No newline at end of file
`
const output = diff.parse(str)
assert.deepEqual(output, [
{
oldPath: 'file.txt',
newPath: 'file.txt',
oldMode: '100644',
newMode: '100644',
status: 'modified',
hunks: [
{
oldStartLine: 1,
oldLineCount: 1,
newStartLine: 1,
newLineCount: 1,
heading: '',
lines: [
'-line',
'+line',
'\ No newline at end of file'
]
}
],
binary: false
}
])
test.done()
}
exports.testAddedEOFNL = function(test) {
var str = dedent`
diff --git file.txt file.txt
index 266014b..a999a0c 100644
--- file.txt
+++ file.txt
@@ -1 +1 @@
-line
\ No newline at end of file
+line
`
const output = diff.parse(str)
assert.deepEqual(output, [
{
oldPath: 'file.txt',
newPath: 'file.txt',
oldMode: '100644',
newMode: '100644',
status: 'modified',
hunks: [
{
oldStartLine: 1,
oldLineCount: 1,
newStartLine: 1,
newLineCount: 1,
heading: '',
lines: [
'-line',
'\ No newline at end of file',
'+line'
]
}
],
binary: false
}
])
test.done()
}
exports.testEmptyHunkLine = function(test) {
var str = dedent`
diff --git file.txt file.txt
index 83db48f..bf269f4 100644
--- file.txt
+++ file.txt
@@ -1,3 +1,3 @@
line1
-line2
+
line3
`
const output = diff.parse(str)
assert.deepEqual(output, [
{
oldPath: 'file.txt',
newPath: 'file.txt',
oldMode: '100644',
newMode: '100644',
status: 'modified',
hunks: [
{
oldStartLine: 1,
oldLineCount: 3,
newStartLine: 1,
newLineCount: 3,
heading: '',
lines: [
' line1',
'-line2',
'+',
' line3'
]
}
],
binary: false
}
])
test.done()
}
exports.testMergeConflicts = function(test) {
var str = dedent`
diff --cc modified-on-both.txt
index 5b7855c,1353022..0000000
--- modified-on-both.txt
+++ modified-on-both.txt
@@@ -1,1 -1,1 +1,7 @@@ some context
++<<<<<<< HEAD
+master modification
++||||||| merged common ancestors
++text
++=======
+ branch modification
++>>>>>>> branch
* Unmerged path removed-on-branch.txt
* Unmerged path removed-on-master.txt
diff --cc image.gif
index e6551c7,5f88da9..0000000
Binary files differ
`
const output = diff.parse(str)
assert.deepEqual(output, [
{
filePath: 'modified-on-both.txt',
status: 'unmerged',
hunks: [
{
ourStartLine: 1,
ourLineCount: 1,
baseStartLine: 1,
baseLineCount: 1,
theirStartLine: 1,
theirLineCount: 7,
heading: 'some context',
lines: [
'++<<<<<<< HEAD',
' +master modification',
'++||||||| merged common ancestors',
'++text',
'++=======',
'+ branch modification',
'++>>>>>>> branch'
]
}
],
binary: false
},
{
filePath: 'removed-on-branch.txt',
status: 'unmerged',
binary: false
},
{
filePath: 'removed-on-master.txt',
status: 'unmerged',
binary: false
},
{
filePath: 'image.gif',
status: 'unmerged',
binary: true
}
])
test.done()
}
exports.testBinaryFiles = function(test) {
var str = dedent`
diff --git one.gif one.gif
new file mode 100644
index 0000000..9243b23
Binary files /dev/null and one.gif differ
diff --git two.gif two.gif
index 9243b23..e26b70a 100644
Binary files two.gif and two.gif differ
diff --git three.gif three.gif
deleted file mode 100644
index e26b70a..0000000
Binary files three.gif and /dev/null differ
diff --git a/cat.png b/cat.png
new file mode 100644
index 0000000..8b8dc61
--- /dev/null
+++ b/cat.png
Binary files differ
`
const output = diff.parse(str)
assert.deepEqual(output, [
{
oldPath: null,
newPath: 'one.gif',
oldMode: null,
newMode: '100644',
status: 'added',
hunks: [],
binary: true
},
{
oldPath: 'two.gif',
newPath: 'two.gif',
oldMode: '100644',
newMode: '100644',
status: 'modified',
hunks: [],
binary: true
},
{
oldPath: 'three.gif',
newPath: null,
oldMode: '100644',
newMode: null,
status: 'deleted',
hunks: [],
binary: true
},
{
oldPath: null,
newPath: 'b/cat.png',
hunks: [],
oldMode: null,
newMode: '100644',
status: 'added',
binary: true
}
])
test.done()
}
exports.testBinaryFilesRename = function(test) {
var str = dedent`
diff --git a/dir_a/one.png b/dir_b/one.png
similarity index 100%
rename from dir_a/one.png
rename to dir_b/one.png
Binary files differ
`
const output = diff.parse(str)
assert.deepEqual(output, [
{
oldPath: 'dir_a/one.png',
newPath: 'dir_b/one.png',
hunks: undefined,
status: 'renamed',
similarity: 100
}
])
test.done()
}
exports.testNoPatch = function(test) {
var str = dedent`
diff --git file.txt file.txt
old mode 100644
new mode 100755
`
const output = diff.parse(str)
assert.deepEqual(output, [
{
oldPath: 'file.txt',
newPath: 'file.txt',
oldMode: '100644',
newMode: '100755',
status: 'modified',
hunks: [],
binary: false
},
])
test.done()
}
exports.testRenameCopy = function(test) {
var str = dedent`
diff --git old/file.png new/file.png
similarity index 90%
rename from old/file.png
rename to new/file.png
diff --git copy/file.png copy/file2.png
similarity index 100%
copy from copy/file.png
copy to copy/file2.png
`
const output = diff.parse(str)
assert.deepEqual(output, [
{
oldPath: 'old/file.png',
newPath: 'new/file.png',
status: 'renamed',
similarity: 90,
hunks: [],
},
{
oldPath: 'copy/file.png',
newPath: 'copy/file2.png',
status: 'copied',
similarity: 100,
hunks: [],
},
])
test.done()
}
exports.testRenameWithChangedLinesAndModeChange = function(test) {
var str = dedent`
diff --git file.txt rename-file.txt
old mode 100644
new mode 100755
similarity index 76%
rename from file.txt
rename to rename-file.txt
index 471a7b8..3e32ec2
--- file.txt
+++ rename-file.txt
@@ -1,4 +1,5 @@
foo
bar
baz
+qux
`;
const output = diff.parse(str)
assert.deepEqual(output, [
{
oldPath: "file.txt",
newPath: "rename-file.txt",
oldMode: "100644",
newMode: "100755",
status: "renamed",
similarity: 76,
hunks: [{
oldStartLine: 1,
oldLineCount: 4,
newStartLine: 1,
newLineCount: 5,
heading: '',
lines: [' foo', ' bar', ' baz', '+qux']
}]
}
]);
test.done()
}
exports.testMergeConflictNoPatch = function(test) {
var str = dedent`
diff --cc file-0.txt
index 1fbec74,3bfc451..0000000
--- file-0.txt
+++ file-0.txt
`
const output = diff.parse(str)
assert.deepEqual(output, [
{
filePath: 'file-0.txt',
status: 'unmerged',
hunks: [],
binary: false
}
])
test.done()
}