FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nodegit/test/tests/config.js at v0.7.0 · nodegit/nodegit · GitHub
nodegit
nodegit
Repository navigation
Code
Issues
344
(344)
Pull requests
23
(23)
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
99 lines (87 loc) · 2.62 KB
Breadcrumbs
nodegit
/
test
/
tests
/
config.js
Copy path
File metadata and controls
99 lines (87 loc) · 2.62 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
var
assert
=
require
(
"assert"
)
;
var
path
=
require
(
"path"
)
;
var
local
=
path
.
join
.
bind
(
path
,
__dirname
)
;
var
promisify
=
require
(
"promisify-node"
)
;
// Have to wrap exec, since it has a weird callback signature.
var
exec
=
promisify
(
function
(
command
,
opts
,
callback
)
{
return
require
(
"child_process"
)
.
exec
(
command
,
opts
,
callback
)
;
}
)
;
describe
(
"Config"
,
function
(
)
{
var
NodeGit
=
require
(
"../../"
)
;
var
reposPath
=
local
(
"../repos/workdir"
)
;
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
;
}
)
;
}
)
;
}
)
;
}
)
;
Back
|
FazBrowse Home
|
New Git URL