FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nodegit/lib/diff.js at master · miklen/nodegit · GitHub
miklen
nodegit
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
nodegit
/
lib
/
diff.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
103 lines (89 loc) · 2.74 KB
Breadcrumbs
nodegit
/
lib
/
diff.js
Copy path
File metadata and controls
103 lines (89 loc) · 2.74 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
var
NodeGit
=
require
(
"../"
)
;
var
Promise
=
require
(
"nodegit-promise"
)
;
var
Diff
=
NodeGit
.
Diff
;
var
ConvenientPatch
=
NodeGit
.
ConvenientPatch
;
var
normalizeOptions
=
NodeGit
.
Utils
.
normalizeOptions
;
var
Patch
=
NodeGit
.
Patch
;
/**
* Retrieve patches in this difflist
*
*
@return
Promise({[ConvenientPatch]}) a promise that resolves to an array of
* ConvenientPatches
*/
Diff
.
prototype
.
patches
=
function
(
)
{
var
_this
=
this
;
var
size
=
_this
.
numDeltas
(
)
;
var
patchPromises
=
[
]
;
var
i
;
function
makePatchPromise
(
i
)
{
return
Patch
.
fromDiff
(
_this
,
i
)
.
then
(
function
(
patch
)
{
return
new
ConvenientPatch
(
_this
.
getDelta
(
i
)
,
patch
,
i
)
;
}
)
;
}
for
(
i
=
0
;
i
<
size
;
i
++
)
{
patchPromises
.
push
(
makePatchPromise
(
i
)
)
;
}
return
Promise
.
all
(
patchPromises
)
;
}
;
// Override Diff.indexToWorkdir to normalize opts
var
indexToWorkdir
=
Diff
.
indexToWorkdir
;
Diff
.
indexToWorkdir
=
function
(
repo
,
index
,
opts
)
{
opts
=
normalizeOptions
(
opts
,
NodeGit
.
DiffOptions
)
;
return
indexToWorkdir
(
repo
,
index
,
opts
)
;
}
;
// Override Diff.treeToIndex to normalize opts
var
treeToIndex
=
Diff
.
treeToIndex
;
Diff
.
treeToIndex
=
function
(
repo
,
tree
,
index
,
opts
)
{
opts
=
normalizeOptions
(
opts
,
NodeGit
.
DiffOptions
)
;
return
treeToIndex
(
repo
,
tree
,
index
,
opts
)
;
}
;
// Override Diff.treeToTree to normalize opts
var
treeToTree
=
Diff
.
treeToTree
;
Diff
.
treeToTree
=
function
(
repo
,
from_tree
,
to_tree
,
opts
)
{
opts
=
normalizeOptions
(
opts
,
NodeGit
.
DiffOptions
)
;
return
treeToTree
(
repo
,
from_tree
,
to_tree
,
opts
)
;
}
;
// Override Diff.treeToWorkdir to normalize opts
var
treeToWorkdir
=
Diff
.
treeToWorkdir
;
Diff
.
treeToWorkdir
=
function
(
repo
,
tree
,
opts
)
{
opts
=
normalizeOptions
(
opts
,
NodeGit
.
DiffOptions
)
;
return
treeToWorkdir
(
repo
,
tree
,
opts
)
;
}
;
// Override Diff.treeToWorkdir to normalize opts
var
treeToWorkdirWithIndex
=
Diff
.
treeToWorkdirWithIndex
;
Diff
.
treeToWorkdirWithIndex
=
function
(
repo
,
tree
,
opts
)
{
opts
=
normalizeOptions
(
opts
,
NodeGit
.
DiffOptions
)
;
return
treeToWorkdirWithIndex
(
repo
,
tree
,
opts
)
;
}
;
// Override Diff.findSimilar to normalize opts
var
findSimilar
=
Diff
.
prototype
.
findSimilar
;
Diff
.
prototype
.
findSimilar
=
function
(
opts
)
{
opts
=
normalizeOptions
(
opts
,
NodeGit
.
DiffFindOptions
)
;
return
findSimilar
.
call
(
this
,
opts
)
;
}
;
var
blobToBuffer
=
Diff
.
blobToBuffer
;
Diff
.
blobToBuffer
=
function
(
old_blob
,
old_as_path
,
buffer
,
buffer_as_path
,
opts
,
file_cb
,
hunk_cb
,
line_cb
)
{
var
bufferLength
=
!
buffer
?
0
:
buffer
.
length
;
opts
=
normalizeOptions
(
opts
,
NodeGit
.
DiffOptions
)
;
return
blobToBuffer
.
call
(
this
,
old_blob
,
old_as_path
,
buffer
,
bufferLength
,
buffer_as_path
,
opts
,
file_cb
,
hunk_cb
,
line_cb
,
null
)
;
}
;
Back
|
FazBrowse Home
|
New Git URL