FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nodegit/test/tests/patch.js at master · JJ/nodegit · GitHub
JJ
nodegit
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
nodegit
/
test
/
tests
/
patch.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
67 lines (53 loc) · 1.71 KB
Breadcrumbs
nodegit
/
test
/
tests
/
patch.js
Copy path
File metadata and controls
67 lines (53 loc) · 1.71 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
var
assert
=
require
(
"assert"
)
;
var
path
=
require
(
"path"
)
;
var
Promise
=
require
(
"nodegit-promise"
)
;
var
local
=
path
.
join
.
bind
(
path
,
__dirname
)
;
describe
(
"Patch"
,
function
(
)
{
var
NodeGit
=
require
(
"../../"
)
;
var
Repository
=
NodeGit
.
Repository
;
var
reposPath
=
local
(
"../repos/workdir"
)
;
var
oid
=
"fce88902e66c72b5b93e75bdb5ae717038b221f6"
;
beforeEach
(
function
(
)
{
var
test
=
this
;
return
Repository
.
open
(
reposPath
)
.
then
(
function
(
repository
)
{
test
.
repository
=
repository
;
return
repository
.
openIndex
(
)
;
}
)
.
then
(
function
(
index
)
{
test
.
index
=
index
;
return
test
.
repository
.
getBranchCommit
(
"master"
)
;
}
)
.
then
(
function
(
masterCommit
)
{
return
masterCommit
.
getTree
(
)
;
}
)
.
then
(
function
(
tree
)
{
test
.
masterCommitTree
=
tree
;
return
test
.
repository
.
getCommit
(
oid
)
;
}
)
.
then
(
function
(
commit
)
{
test
.
commit
=
commit
;
return
commit
.
getDiff
(
)
;
}
)
.
then
(
function
(
diff
)
{
test
.
diff
=
diff
;
return
diff
[
0
]
.
patches
(
)
;
}
)
.
catch
(
function
(
e
)
{
return
Promise
.
reject
(
e
)
;
}
)
;
}
)
;
it
(
"retrieve the line stats of a patch"
,
function
(
)
{
return
this
.
diff
[
0
]
.
patches
(
)
.
then
(
function
(
patches
)
{
var
patch
=
patches
[
0
]
;
var
lineStats
=
patch
.
lineStats
(
)
;
assert
.
equal
(
patch
.
oldFile
(
)
.
path
(
)
,
"README.md"
)
;
assert
.
equal
(
patch
.
newFile
(
)
.
path
(
)
,
"README.md"
)
;
assert
.
equal
(
patch
.
size
(
)
,
1
)
;
assert
.
ok
(
patch
.
isModified
(
)
)
;
assert
.
equal
(
lineStats
.
total_context
,
3
)
;
assert
.
equal
(
lineStats
.
total_additions
,
1
)
;
assert
.
equal
(
lineStats
.
total_deletions
,
1
)
;
}
)
;
}
)
;
}
)
;
Back
|
FazBrowse Home
|
New Git URL