FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nodegit/test/tests/submodule.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
/
submodule.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
160 lines (138 loc) · 4.69 KB
Breadcrumbs
nodegit
/
test
/
tests
/
submodule.js
Copy path
File metadata and controls
160 lines (138 loc) · 4.69 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
var
assert
=
require
(
"assert"
)
;
var
path
=
require
(
"path"
)
;
var
local
=
path
.
join
.
bind
(
path
,
__dirname
)
;
describe
(
"Submodule"
,
function
(
)
{
var
NodeGit
=
require
(
"../../"
)
;
var
Repository
=
NodeGit
.
Repository
;
var
RepoUtils
=
require
(
"../utils/repository_setup"
)
;
var
Submodule
=
NodeGit
.
Submodule
;
var
repoPath
=
local
(
"../repos/submodule"
)
;
beforeEach
(
function
(
)
{
var
test
=
this
;
return
RepoUtils
.
createRepository
(
repoPath
)
.
then
(
function
(
repo
)
{
test
.
repository
=
repo
;
return
Repository
.
open
(
local
(
"../repos/workdir"
)
)
;
}
)
.
then
(
function
(
repo
)
{
test
.
workdirRepository
=
repo
;
}
)
;
}
)
;
it
(
"can walk over the submodules"
,
function
(
)
{
var
repo
=
this
.
workdirRepository
;
var
submoduleName
=
"vendor/libgit2"
;
return
repo
.
getSubmoduleNames
(
)
.
then
(
function
(
submodules
)
{
assert
.
equal
(
submodules
.
length
,
1
)
;
var
submodule
=
submodules
[
0
]
;
assert
.
equal
(
submodule
,
submoduleName
)
;
return
submodule
;
}
)
.
then
(
function
(
submodule
)
{
return
Submodule
.
lookup
(
repo
,
submodule
)
;
}
)
.
then
(
function
(
submodule
)
{
assert
.
equal
(
submodule
.
name
(
)
,
submoduleName
)
;
}
)
;
}
)
;
it
(
"can get submodule status"
,
function
(
)
{
var
repo
=
this
.
workdirRepository
;
var
submoduleName
=
"vendor/libgit2"
;
return
Submodule
.
status
(
repo
,
submoduleName
,
Submodule
.
IGNORE
.
NONE
)
.
then
(
function
(
status
)
{
assert
.
equal
(
Submodule
.
STATUS
.
IN_CONFIG
,
status
)
;
}
)
;
}
)
;
it
(
"can get submodule location"
,
function
(
)
{
var
repo
=
this
.
workdirRepository
;
var
submoduleName
=
"vendor/libgit2"
;
return
Submodule
.
lookup
(
repo
,
submoduleName
)
.
then
(
function
(
submodule
)
{
return
submodule
.
location
(
)
;
}
)
.
then
(
function
(
status
)
{
assert
.
equal
(
Submodule
.
STATUS
.
IN_CONFIG
,
status
)
;
}
)
;
}
)
;
it
(
"can set submodule ignore"
,
function
(
)
{
var
repo
=
this
.
workdirRepository
;
var
submoduleName
=
"vendor/libgit2"
;
return
Submodule
.
setIgnore
(
repo
,
submoduleName
,
Submodule
.
IGNORE
.
ALL
)
.
then
(
function
(
)
{
return
Submodule
.
lookup
(
repo
,
submoduleName
)
;
}
)
.
then
(
function
(
submodule
)
{
assert
.
equal
(
Submodule
.
IGNORE
.
ALL
,
submodule
.
ignore
(
)
)
;
}
)
;
}
)
;
it
(
"can set submodule url"
,
function
(
)
{
var
repo
=
this
.
workdirRepository
;
var
submoduleName
=
"vendor/libgit2"
;
var
submoduleUrl
=
"https://github.com/githubtraining/hellogitworld.git"
;
return
Submodule
.
setUrl
(
repo
,
submoduleName
,
submoduleUrl
)
.
then
(
function
(
)
{
return
Submodule
.
lookup
(
repo
,
submoduleName
)
;
}
)
.
then
(
function
(
submodule
)
{
assert
.
equal
(
submoduleUrl
,
submodule
.
url
(
)
)
;
}
)
;
}
)
;
it
(
"can set submodule update"
,
function
(
)
{
var
repo
=
this
.
workdirRepository
;
var
submoduleName
=
"vendor/libgit2"
;
return
Submodule
.
setUpdate
(
repo
,
submoduleName
,
Submodule
.
UPDATE
.
NONE
)
.
then
(
function
(
)
{
return
Submodule
.
lookup
(
repo
,
submoduleName
)
;
}
)
.
then
(
function
(
submodule
)
{
assert
.
equal
(
Submodule
.
UPDATE
.
NONE
,
submodule
.
updateStrategy
(
)
)
;
}
)
;
}
)
;
it
(
"can setup and finalize submodule add"
,
function
(
)
{
this
.
timeout
(
30000
)
;
var
repo
=
this
.
repository
;
var
submodulePath
=
"nodegittest"
;
var
submoduleUrl
=
"https://github.com/nodegit/test.git"
;
var
submodule
;
var
submoduleRepo
;
return
NodeGit
.
Submodule
.
addSetup
(
repo
,
submoduleUrl
,
submodulePath
,
0
)
.
then
(
function
(
_submodule
)
{
submodule
=
_submodule
;
return
submodule
.
init
(
0
)
;
}
)
.
then
(
function
(
)
{
return
submodule
.
open
(
)
;
}
)
.
then
(
function
(
_submoduleRepo
)
{
submoduleRepo
=
_submoduleRepo
;
return
submoduleRepo
.
fetch
(
"origin"
,
null
,
null
)
;
}
)
.
then
(
function
(
)
{
return
submoduleRepo
.
getReference
(
"origin/master"
)
;
}
)
.
then
(
function
(
reference
)
{
return
reference
.
peel
(
NodeGit
.
Object
.
TYPE
.
COMMIT
)
;
}
)
.
then
(
function
(
commit
)
{
return
submoduleRepo
.
createBranch
(
"master"
,
commit
.
id
(
)
)
;
}
)
.
then
(
function
(
)
{
return
submodule
.
addFinalize
(
)
;
}
)
.
then
(
function
(
)
{
// check whether the submodule exists
return
Submodule
.
lookup
(
repo
,
submodulePath
)
;
}
)
.
then
(
function
(
submodule
)
{
assert
.
equal
(
submodule
.
name
(
)
,
submodulePath
)
;
// check whether .gitmodules and the submodule are in the index
return
repo
.
refreshIndex
(
)
;
}
)
.
then
(
function
(
index
)
{
var
entries
=
index
.
entries
(
)
;
assert
.
equal
(
entries
.
length
,
2
)
;
assert
.
equal
(
entries
[
0
]
.
path
,
".gitmodules"
)
;
assert
.
equal
(
entries
[
1
]
.
path
,
submodulePath
)
;
}
)
;
}
)
;
}
)
;
Back
|
FazBrowse Home
|
New Git URL