FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nodegit/test/tests/tree_entry.js at master · codercatdev/nodegit · GitHub
codercatdev
nodegit
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
nodegit
/
test
/
tests
/
tree_entry.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
191 lines (165 loc) · 5.1 KB
Breadcrumbs
nodegit
/
test
/
tests
/
tree_entry.js
Copy path
File metadata and controls
191 lines (165 loc) · 5.1 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
var
assert
=
require
(
"assert"
)
;
var
path
=
require
(
"path"
)
;
var
local
=
path
.
join
.
bind
(
path
,
__dirname
)
;
var
leakTest
=
require
(
"../utils/leak_test"
)
;
describe
(
"TreeEntry"
,
function
(
)
{
var
NodeGit
=
require
(
"../../"
)
;
var
Repository
=
NodeGit
.
Repository
;
var
Tree
=
NodeGit
.
Tree
;
var
reposPath
=
local
(
"../repos/workdir"
)
;
var
oid
=
"5716e9757886eaf38d51c86b192258c960d9cfea"
;
beforeEach
(
function
(
)
{
var
test
=
this
;
return
Repository
.
open
(
reposPath
)
.
then
(
function
(
repository
)
{
test
.
repository
=
repository
;
return
repository
.
getCommit
(
oid
)
;
}
)
.
then
(
function
(
commit
)
{
test
.
commit
=
commit
;
}
)
;
}
)
;
it
(
"will fail on a missing file"
,
function
(
)
{
return
this
.
commit
.
getEntry
(
"test/-entry.js"
)
.
then
(
null
,
function
(
err
)
{
assert
.
ok
(
err
instanceof
Error
)
;
}
)
;
}
)
;
it
(
"provides the correct sha for a file"
,
function
(
)
{
return
this
.
commit
.
getEntry
(
"README.md"
)
.
then
(
function
(
entry
)
{
assert
.
equal
(
entry
.
sha
(
)
,
"6cb45ba5d32532bf0d1310dc31ca4f20f59964bc"
)
;
}
)
;
}
)
;
it
(
"provides the correct length for a file"
,
function
(
)
{
return
this
.
commit
.
getEntry
(
"README.md"
)
.
then
(
function
(
entry
)
{
assert
.
equal
(
entry
.
name
(
)
.
length
,
9
)
;
}
)
;
}
)
;
it
(
"provides the filename"
,
function
(
)
{
return
this
.
commit
.
getEntry
(
"test/raw-commit.js"
)
.
then
(
function
(
entry
)
{
assert
.
equal
(
entry
.
name
(
)
,
"raw-commit.js"
)
;
}
)
;
}
)
;
it
(
"provides the full path"
,
function
(
)
{
return
this
.
commit
.
getEntry
(
"test/raw-commit.js"
)
.
then
(
function
(
entry
)
{
assert
.
equal
(
entry
.
path
(
)
,
"test/raw-commit.js"
)
;
}
)
;
}
)
;
it
(
"provides the full path when the entry came from a tree"
,
function
(
done
)
{
var
testTree
=
function
(
tree
,
_dir
)
{
var
dir
=
_dir
||
""
,
testPromises
=
[
]
;
tree
.
entries
(
)
.
forEach
(
function
(
entry
)
{
var
currentPath
=
path
.
posix
.
join
(
dir
,
entry
.
name
(
)
)
;
if
(
entry
.
isTree
(
)
)
{
testPromises
.
push
(
entry
.
getTree
(
)
.
then
(
function
(
subtree
)
{
return
testTree
(
subtree
,
currentPath
)
;
}
)
)
;
}
else
{
assert
.
equal
(
entry
.
path
(
)
,
currentPath
)
;
}
}
)
;
return
Promise
.
all
(
testPromises
)
;
}
;
return
this
.
commit
.
getTree
(
)
.
then
(
testTree
)
.
done
(
function
(
)
{
done
(
)
;
}
)
;
}
)
;
it
(
"provides the blob representation of the entry"
,
function
(
)
{
return
this
.
commit
.
getEntry
(
"test/raw-commit.js"
)
.
then
(
function
(
entry
)
{
return
entry
.
getBlob
(
)
;
}
)
.
then
(
function
(
blob
)
{
assert
.
equal
(
blob
.
rawsize
(
)
,
2736
)
;
}
)
;
}
)
;
it
(
"provides the blob representation via callback"
,
function
(
)
{
return
this
.
commit
.
getEntry
(
"test/raw-commit.js"
)
.
then
(
function
(
entry
)
{
entry
.
getBlob
(
function
(
error
,
blob
)
{
assert
.
equal
(
blob
.
rawsize
(
)
,
2736
)
;
}
)
;
}
)
;
}
)
;
it
(
"provides the tree the entry is part of"
,
function
(
)
{
return
this
.
commit
.
getEntry
(
"test"
)
.
then
(
function
(
entry
)
{
return
entry
.
getTree
(
)
;
}
)
.
then
(
function
(
tree
)
{
assert
.
ok
(
tree
instanceof
Tree
)
;
}
)
;
}
)
;
it
(
"can determine if an entry is a file"
,
function
(
)
{
return
this
.
commit
.
getEntry
(
"README.md"
)
.
then
(
function
(
entry
)
{
assert
.
ok
(
entry
.
isFile
(
)
)
;
}
)
;
}
)
;
it
(
"can determine if an entry is not a file"
,
function
(
)
{
return
this
.
commit
.
getEntry
(
"example"
)
.
then
(
function
(
entry
)
{
assert
.
equal
(
entry
.
isFile
(
)
,
false
)
;
}
)
;
}
)
;
it
(
"can determine if an entry is a directory"
,
function
(
)
{
return
this
.
commit
.
getEntry
(
"example"
)
.
then
(
function
(
entry
)
{
assert
.
equal
(
entry
.
isDirectory
(
)
,
true
)
;
}
)
;
}
)
;
it
(
"can determine if an entry is a submodule"
,
function
(
)
{
var
repo
=
this
.
repository
;
return
repo
.
getCommit
(
"878ef6efbc5f85c4f63aeedf41addc262a621308"
)
.
then
(
function
(
commit
)
{
return
commit
.
getEntry
(
"vendor/libgit2"
)
.
then
(
function
(
entry
)
{
assert
.
equal
(
entry
.
isSubmodule
(
)
,
true
)
;
}
)
;
}
)
;
}
)
;
it
(
"can determine if an entry is not a submodule"
,
function
(
)
{
return
this
.
commit
.
getEntry
(
"example"
)
.
then
(
function
(
entry
)
{
assert
.
equal
(
entry
.
isSubmodule
(
)
,
false
)
;
}
)
;
}
)
;
it
(
"can convert entry into a blob"
,
function
(
)
{
var
repo
=
this
.
repository
;
return
this
.
commit
.
getEntry
(
"README.md"
)
.
then
(
function
(
entry
)
{
return
entry
.
toObject
(
repo
)
;
}
)
.
then
(
function
(
object
)
{
assert
.
equal
(
object
.
isBlob
(
)
,
true
)
;
}
)
;
}
)
;
it
(
"can convert entry into a tree"
,
function
(
)
{
var
repo
=
this
.
repository
;
return
this
.
commit
.
getEntry
(
"example"
)
.
then
(
function
(
entry
)
{
return
entry
.
toObject
(
repo
)
;
}
)
.
then
(
function
(
object
)
{
assert
.
equal
(
object
.
isTree
(
)
,
true
)
;
}
)
;
}
)
;
it
(
"does not leak"
,
function
(
)
{
var
test
=
this
;
return
leakTest
(
NodeGit
.
TreeEntry
,
function
(
)
{
return
test
.
commit
.
getTree
(
)
.
then
(
function
(
tree
)
{
return
tree
.
entryByPath
(
"example"
)
;
}
)
;
}
)
;
}
)
;
}
)
;
Back
|
FazBrowse Home
|
New Git URL