FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nodegit/test/tests/config.js at master · nodegit/nodegit · GitHub
nodegit
nodegit
Repository navigation
Code
Issues
344
(344)
Pull requests
21
(21)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
nodegit
/
test
/
tests
/
config.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
210 lines (191 loc) · 5.86 KB
Breadcrumbs
nodegit
/
test
/
tests
/
config.js
Copy path
File metadata and controls
210 lines (191 loc) · 5.86 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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
var
assert
=
require
(
"assert"
)
;
var
path
=
require
(
"path"
)
;
var
local
=
path
.
join
.
bind
(
path
,
__dirname
)
;
var
exec
=
require
(
"../../utils/execPromise"
)
;
describe
(
"Config"
,
function
(
)
{
var
NodeGit
=
require
(
"../../"
)
;
var
Repository
=
NodeGit
.
Repository
;
var
Config
=
NodeGit
.
Config
;
var
reposPath
=
local
(
"../repos/workdir"
)
;
describe
(
"openOnDisk"
,
function
(
)
{
var
configPath
=
path
.
join
(
reposPath
,
".git/config"
)
;
it
(
"opens the same config as the repo"
,
function
(
)
{
var
repo
;
var
onDiskConfig
;
return
Repository
.
open
(
reposPath
)
.
then
(
function
(
_repo
)
{
repo
=
_repo
;
return
Config
.
openOndisk
(
configPath
)
;
}
)
.
then
(
function
(
config
)
{
onDiskConfig
=
config
;
return
repo
.
config
(
)
;
}
)
.
then
(
function
(
repoConfig
)
{
return
Promise
.
all
(
[
onDiskConfig
.
getString
(
"core.filemode"
)
,
onDiskConfig
.
getString
(
"core.bare"
)
,
repoConfig
.
getString
(
"core.filemode"
)
,
repoConfig
.
getString
(
"core.bare"
)
]
)
;
}
)
.
then
(
function
(
results
)
{
var
onDiskFileMode
=
results
[
0
]
;
var
onDiskBare
=
results
[
1
]
;
var
repoFileMode
=
results
[
2
]
;
var
repoBare
=
results
[
3
]
;
assert
.
equal
(
onDiskFileMode
,
repoFileMode
)
;
assert
.
equal
(
onDiskBare
,
repoBare
)
;
}
)
;
}
)
;
it
(
"opens the config and can change a value"
,
function
(
)
{
var
repo
;
var
onDiskConfig
;
var
repoConfig
;
var
originalFileMode
;
return
Repository
.
open
(
reposPath
)
.
then
(
function
(
_repo
)
{
repo
=
_repo
;
return
Config
.
openOndisk
(
configPath
)
;
}
)
.
then
(
function
(
config
)
{
onDiskConfig
=
config
;
return
repo
.
config
(
)
;
}
)
.
then
(
function
(
_repoConfig
)
{
repoConfig
=
_repoConfig
;
return
Promise
.
all
(
[
onDiskConfig
.
getString
(
"core.filemode"
)
,
repoConfig
.
getString
(
"core.filemode"
)
]
)
;
}
)
.
then
(
function
(
results
)
{
var
onDiskFileMode
=
results
[
0
]
;
var
repoFileMode
=
results
[
1
]
;
assert
.
equal
(
onDiskFileMode
,
repoFileMode
)
;
originalFileMode
=
onDiskFileMode
;
var
oppositeFileMode
=
onDiskFileMode
===
"true"
?
"false"
:
"true"
;
return
onDiskConfig
.
setString
(
"core.filemode"
,
oppositeFileMode
)
;
}
)
.
then
(
function
(
)
{
return
Config
.
openOndisk
(
configPath
)
;
}
)
.
then
(
function
(
config
)
{
return
Promise
.
all
(
[
config
.
getString
(
"core.filemode"
)
,
repoConfig
.
getString
(
"core.filemode"
)
]
)
;
}
)
.
then
(
function
(
results
)
{
var
onDiskFileMode
=
results
[
0
]
;
var
repoFileMode
=
results
[
1
]
;
assert
.
notEqual
(
onDiskFileMode
,
originalFileMode
)
;
assert
.
equal
(
onDiskFileMode
,
repoFileMode
)
;
}
)
.
then
(
function
(
)
{
// cleanup
return
onDiskConfig
.
setString
(
"core.filemode"
,
originalFileMode
)
;
}
)
;
}
)
;
}
)
;
it
(
"can get and set a global value"
,
function
(
)
{
var
savedUserName
;
function
finallyFn
(
)
{
return
exec
(
"git config --global user.name \""
+
savedUserName
+
"\""
)
;
}
return
exec
(
"git config --global user.name"
)
.
then
(
function
(
userName
)
{
savedUserName
=
userName
.
trim
(
)
;
return
exec
(
"git config --global user.name \""
+
savedUserName
+
"-test\""
)
;
}
)
.
then
(
function
(
)
{
return
NodeGit
.
Config
.
openDefault
(
)
;
}
)
.
then
(
function
(
config
)
{
return
config
.
getString
(
"user.name"
)
;
}
)
.
then
(
function
(
userNameFromNodeGit
)
{
assert
.
equal
(
savedUserName
+
"-test"
,
userNameFromNodeGit
)
;
}
)
.
then
(
finallyFn
)
.
catch
(
function
(
e
)
{
return
finallyFn
(
)
.
then
(
function
(
)
{
throw
e
;
}
)
;
}
)
;
}
)
;
it
(
"will reject when getting value of non-existent config key"
,
function
(
)
{
// Test initially for finding source of a segfault. There was a problem
// where getting an empty config value crashes nodegit.
return
NodeGit
.
Config
.
openDefault
(
)
.
then
(
function
(
config
)
{
return
config
.
getString
(
"user.fakevalue"
)
;
}
)
.
catch
(
function
(
e
)
{
return
true
;
}
)
;
}
)
;
it
(
"can get and set a repo config value"
,
function
(
)
{
var
savedUserName
;
function
finallyFn
(
)
{
return
exec
(
"git config user.name \""
+
savedUserName
+
"\""
,
{
cwd
:
reposPath
}
)
;
}
return
exec
(
"git config user.name"
,
{
cwd
:
reposPath
}
)
.
then
(
function
(
userName
)
{
savedUserName
=
userName
.
trim
(
)
;
return
exec
(
"git config user.name \""
+
savedUserName
+
"-test\""
,
{
cwd
:
reposPath
}
)
;
}
)
.
then
(
function
(
)
{
return
NodeGit
.
Repository
.
open
(
reposPath
)
;
}
)
.
then
(
function
(
repo
)
{
return
repo
.
config
(
)
;
}
)
.
then
(
function
(
config
)
{
return
config
.
getString
(
"user.name"
)
;
}
)
.
then
(
function
(
userNameFromNodeGit
)
{
assert
.
equal
(
savedUserName
+
"-test"
,
userNameFromNodeGit
)
;
}
)
.
then
(
finallyFn
)
.
catch
(
function
(
e
)
{
return
finallyFn
(
)
.
then
(
function
(
)
{
throw
e
;
}
)
;
}
)
;
}
)
;
describe
(
"getPath"
,
function
(
)
{
it
(
"can get path for a given config"
,
function
(
)
{
return
NodeGit
.
Repository
.
open
(
reposPath
)
.
then
(
function
(
repo
)
{
return
repo
.
config
(
)
;
}
)
.
then
(
function
(
config
)
{
return
Promise
.
all
(
[
config
.
getPath
(
"core.filemode"
)
,
config
.
getString
(
"core.filemode"
)
]
)
;
}
)
.
then
(
function
(
results
)
{
var
localFilemode
=
results
[
0
]
;
var
repoFilemode
=
results
[
1
]
;
assert
.
equal
(
localFilemode
,
repoFilemode
)
;
}
)
;
}
)
;
}
)
;
}
)
;
Back
|
FazBrowse Home
|
New Git URL