FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nodegit/test/tests/status.js at master · elfscript/nodegit · GitHub
elfscript
nodegit
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
nodegit
/
test
/
tests
/
status.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
108 lines (97 loc) · 3.13 KB
Breadcrumbs
nodegit
/
test
/
tests
/
status.js
Copy path
File metadata and controls
108 lines (97 loc) · 3.13 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
var
assert
=
require
(
"assert"
)
;
var
path
=
require
(
"path"
)
;
var
promisify
=
require
(
"promisify-node"
)
;
var
fse
=
promisify
(
require
(
"fs-extra"
)
)
;
var
local
=
path
.
join
.
bind
(
path
,
__dirname
)
;
var
exec
=
require
(
"../../utils/execPromise"
)
;
describe
(
"Status"
,
function
(
)
{
var
NodeGit
=
require
(
"../../"
)
;
var
Repository
=
NodeGit
.
Repository
;
var
Status
=
NodeGit
.
Status
;
var
reposPath
=
local
(
"../repos/workdir"
)
;
before
(
function
(
)
{
var
test
=
this
;
return
Repository
.
open
(
reposPath
)
.
then
(
function
(
repository
)
{
test
.
repository
=
repository
;
}
)
;
}
)
;
it
(
"gets no statuses on clean working directory"
,
function
(
)
{
var
statuses
=
[
]
;
var
statusCallback
=
function
(
path
,
status
)
{
statuses
.
push
(
{
path
:
path
,
status
:
status
}
)
;
}
;
return
Status
.
foreach
(
this
.
repository
,
statusCallback
)
.
then
(
function
(
)
{
assert
.
equal
(
statuses
.
length
,
0
)
;
}
)
;
}
)
;
it
(
"gets a status on changing file directory"
,
function
(
)
{
var
fileName
=
"README.md"
;
var
fileContent
=
"Cha-cha-cha-chaaaaaangessssss"
;
var
repo
=
this
.
repository
;
var
filePath
=
path
.
join
(
repo
.
workdir
(
)
,
fileName
)
;
var
oldContent
;
var
statuses
=
[
]
;
return
fse
.
readFile
(
filePath
)
.
then
(
function
(
content
)
{
oldContent
=
content
;
return
fse
.
writeFile
(
filePath
,
fileContent
)
;
}
)
.
then
(
function
(
)
{
var
statusCallback
=
function
(
path
,
status
)
{
statuses
.
push
(
{
path
:
path
,
status
:
status
}
)
;
}
;
return
Status
.
foreach
(
repo
,
statusCallback
)
;
}
)
.
then
(
function
(
)
{
assert
.
equal
(
statuses
.
length
,
1
)
;
assert
.
equal
(
statuses
[
0
]
.
path
,
fileName
)
;
assert
.
equal
(
statuses
[
0
]
.
status
,
256
)
;
}
)
.
then
(
function
(
)
{
return
fse
.
writeFile
(
filePath
,
oldContent
)
;
}
)
.
catch
(
function
(
e
)
{
return
fse
.
writeFile
(
filePath
,
oldContent
)
.
then
(
function
(
)
{
return
Promise
.
reject
(
e
)
;
}
)
;
}
)
;
}
)
;
it
(
"gets status with options"
,
function
(
)
{
var
fileName
=
"my-new-file-that-shouldnt-exist.file"
;
var
fileContent
=
"new file from status tests"
;
var
repo
=
this
.
repository
;
var
filePath
=
path
.
join
(
repo
.
workdir
(
)
,
fileName
)
;
return
exec
(
"git clean -xdf"
,
{
cwd
:
reposPath
}
)
.
then
(
function
(
)
{
return
fse
.
writeFile
(
filePath
,
fileContent
)
;
}
)
.
then
(
function
(
)
{
var
statuses
=
[
]
;
var
statusCallback
=
function
(
path
,
status
)
{
statuses
.
push
(
{
path
:
path
,
status
:
status
}
)
;
}
;
var
opts
=
{
flags
:
Status
.
OPT
.
INCLUDE_UNTRACKED
+
Status
.
OPT
.
RECURSE_UNTRACKED_DIRS
}
;
return
Status
.
foreachExt
(
repo
,
opts
,
statusCallback
)
.
then
(
function
(
)
{
assert
.
equal
(
statuses
.
length
,
1
)
;
assert
.
equal
(
statuses
[
0
]
.
path
,
fileName
)
;
assert
.
equal
(
statuses
[
0
]
.
status
,
128
)
;
}
)
;
}
)
.
then
(
function
(
)
{
return
fse
.
remove
(
filePath
)
;
}
)
.
catch
(
function
(
e
)
{
return
fse
.
remove
(
filePath
)
.
then
(
function
(
)
{
return
Promise
.
reject
(
e
)
;
}
)
;
}
)
;
}
)
;
}
)
;
Back
|
FazBrowse Home
|
New Git URL