FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nodegit.nodegit/test/tests/remote.js at master · javascript-forks/nodegit.nodegit · GitHub
javascript-forks
nodegit.nodegit
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
nodegit.nodegit
/
test
/
tests
/
remote.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
201 lines (168 loc) · 5.31 KB
Breadcrumbs
nodegit.nodegit
/
test
/
tests
/
remote.js
Copy path
File metadata and controls
201 lines (168 loc) · 5.31 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
var
assert
=
require
(
"assert"
)
;
var
path
=
require
(
"path"
)
;
var
Promise
=
require
(
"nodegit-promise"
)
;
var
local
=
path
.
join
.
bind
(
path
,
__dirname
)
;
describe
(
"Remote"
,
function
(
)
{
var
NodeGit
=
require
(
"../../"
)
;
var
Repository
=
NodeGit
.
Repository
;
var
Remote
=
NodeGit
.
Remote
;
var
reposPath
=
local
(
"../repos/workdir"
)
;
var
url
=
"https://github.com/nodegit/test"
;
var
url2
=
"https://github.com/nodegit/test2"
;
function
removeOrigins
(
repository
)
{
Remote
.
delete
(
repository
,
"origin1"
)
;
Remote
.
delete
(
repository
,
"origin2"
)
;
Remote
.
delete
(
repository
,
"origin3"
)
;
Remote
.
delete
(
repository
,
"test2"
)
;
}
beforeEach
(
function
(
)
{
var
test
=
this
;
return
Repository
.
open
(
reposPath
)
.
then
(
function
(
repository
)
{
test
.
repository
=
repository
;
return
Remote
.
lookup
(
repository
,
"origin"
)
;
}
)
.
then
(
function
(
remote
)
{
test
.
remote
=
remote
;
return
removeOrigins
(
test
.
repository
)
;
}
)
;
}
)
;
after
(
function
(
)
{
return
removeOrigins
(
this
.
repository
)
;
}
)
;
it
(
"can load a remote"
,
function
(
)
{
assert
.
ok
(
this
.
remote
instanceof
Remote
)
;
}
)
;
it
(
"can read the remote url"
,
function
(
)
{
assert
.
equal
(
this
.
remote
.
url
(
)
.
replace
(
".git"
,
""
)
,
url
)
;
}
)
;
it
(
"has an empty pushurl by default"
,
function
(
)
{
assert
.
equal
(
this
.
remote
.
pushurl
(
)
,
undefined
)
;
}
)
;
it
(
"can set a remote"
,
function
(
)
{
var
repository
=
this
.
repository
;
var
remote
=
Remote
.
create
(
repository
,
"origin1"
,
url
)
;
remote
.
setPushurl
(
"https://google.com/"
)
;
assert
(
remote
.
pushurl
(
)
,
"https://google.com/"
)
;
}
)
;
it
(
"can read the remote name"
,
function
(
)
{
assert
.
equal
(
this
.
remote
.
name
(
)
,
"origin"
)
;
}
)
;
it
(
"can create and load a new remote"
,
function
(
)
{
var
repository
=
this
.
repository
;
var
remote
=
Remote
.
create
(
repository
,
"origin2"
,
url
)
;
return
Remote
.
lookup
(
repository
,
"origin2"
)
.
then
(
function
(
)
{
assert
(
remote
.
url
(
)
,
url
)
;
}
)
;
}
)
;
it
(
"can delete a remote"
,
function
(
)
{
var
repository
=
this
.
repository
;
Remote
.
create
(
repository
,
"origin3"
,
url
)
;
Remote
.
delete
(
repository
,
"origin3"
)
;
return
Remote
.
lookup
(
repository
,
"origin3"
)
.
then
(
Promise
.
reject
,
Promise
.
resolve
)
;
}
)
;
it
(
"can download from a remote"
,
function
(
)
{
var
repo
=
this
.
repository
;
return
repo
.
getRemote
(
"origin"
)
.
then
(
function
(
remote
)
{
remote
.
setCallbacks
(
{
certificateCheck
:
function
(
)
{
return
1
;
}
}
)
;
return
remote
.
connect
(
NodeGit
.
Enums
.
DIRECTION
.
FETCH
)
.
then
(
function
(
)
{
return
remote
.
download
(
null
)
;
}
)
.
then
(
function
(
)
{
return
remote
.
disconnect
(
)
;
}
)
;
}
)
;
}
)
;
it
(
"can monitor transfer progress while downloading"
,
function
(
)
{
// Set a reasonable timeout here now that our repository has grown.
this
.
timeout
(
600000
)
;
var
repo
=
this
.
repository
;
var
wasCalled
=
false
;
Remote
.
create
(
repo
,
"test2"
,
url2
)
;
return
repo
.
getRemote
(
"test2"
)
.
then
(
function
(
remote
)
{
remote
.
setCallbacks
(
{
credentials
:
function
(
url
,
userName
)
{
return
NodeGit
.
Cred
.
sshKeyFromAgent
(
userName
)
;
}
,
certificateCheck
:
function
(
)
{
return
1
;
}
,
transferProgress
:
function
(
)
{
wasCalled
=
true
;
}
}
)
;
return
remote
.
fetch
(
null
,
repo
.
defaultSignature
(
)
,
null
)
;
}
)
.
then
(
function
(
)
{
assert
.
ok
(
wasCalled
)
;
Remote
.
delete
(
repo
,
"test2"
)
;
}
)
;
}
)
;
it
(
"can fetch from a remote"
,
function
(
)
{
return
this
.
repository
.
fetch
(
"origin"
,
{
credentials
:
function
(
url
,
userName
)
{
return
NodeGit
.
Cred
.
sshKeyFromAgent
(
userName
)
;
}
,
certificateCheck
:
function
(
)
{
return
1
;
}
}
)
;
}
)
;
it
(
"can fetch from all remotes"
,
function
(
)
{
// Set a reasonable timeout here for the fetchAll test
this
.
timeout
(
15000
)
;
return
this
.
repository
.
fetchAll
(
{
credentials
:
function
(
url
,
userName
)
{
return
NodeGit
.
Cred
.
sshKeyFromAgent
(
userName
)
;
}
,
certificateCheck
:
function
(
)
{
return
1
;
}
}
)
;
}
)
;
it
(
"cannot push to a repository"
,
function
(
)
{
this
.
timeout
(
5000
)
;
var
repo
=
this
.
repository
;
var
branch
=
"should-not-exist"
;
return
Remote
.
lookup
(
repo
,
"origin"
)
.
then
(
function
(
remote
)
{
remote
.
setCallbacks
(
{
credentials
:
function
(
url
,
userName
)
{
if
(
url
.
indexOf
(
"https"
)
===
-
1
)
{
return
NodeGit
.
Cred
.
sshKeyFromAgent
(
userName
)
;
}
else
{
return
NodeGit
.
Cred
.
userpassPlaintextNew
(
userName
,
""
)
;
}
}
,
certificateCheck
:
function
(
)
{
return
1
;
}
}
)
;
return
remote
;
}
)
.
then
(
function
(
remote
)
{
var
ref
=
"refs/heads/"
+
branch
;
var
refs
=
[
ref
+
":"
+
ref
]
;
var
signature
=
repo
.
defaultSignature
(
)
;
return
remote
.
push
(
refs
,
null
,
signature
,
"Pushed '"
+
branch
+
"' for test"
)
;
}
)
.
then
(
function
(
)
{
return
Promise
.
reject
(
new
Error
(
"should not be able to push to the repository"
)
)
;
}
,
function
(
err
)
{
if
(
err
.
message
.
indexOf
(
401
)
===
-
1
)
{
throw
err
;
}
else
{
return
Promise
.
resolve
(
)
;
}
}
)
;
}
)
;
}
)
;
Back
|
FazBrowse Home
|
New Git URL