FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nodegit/test/utils/worker_context_aware_checkout.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
/
utils
/
worker_context_aware_checkout.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
66 lines (59 loc) · 1.85 KB
Breadcrumbs
nodegit
/
test
/
utils
/
worker_context_aware_checkout.js
Copy path
File metadata and controls
66 lines (59 loc) · 1.85 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
const
{
isMainThread
,
parentPort
,
workerData
}
=
require
(
"worker_threads"
)
;
const
garbageCollect
=
require
(
"./garbage_collect.js"
)
;
const
assert
=
require
(
"assert"
)
;
const
NodeGit
=
require
(
"../../"
)
;
const
loopingCheckoutHead
=
require
(
"./loop_checkout.js"
)
;
const
{
promisify
}
=
require
(
"util"
)
;
if
(
isMainThread
)
{
throw
new
Error
(
"Must be run via worker thread"
)
;
}
const
{
clonePath
,
url
}
=
workerData
;
const
cloneOpts
=
{
fetchOpts
:
{
callbacks
:
{
certificateCheck
:
(
)
=>
0
}
}
}
;
let
repository
;
let
filterName
=
"psuedo_filter"
;
let
applyCallbackResult
=
1
;
return
NodeGit
.
Clone
(
url
,
clonePath
,
cloneOpts
)
.
then
(
function
(
_repository
)
{
repository
=
_repository
;
assert
.
ok
(
repository
instanceof
NodeGit
.
Repository
)
;
return
NodeGit
.
FilterRegistry
.
register
(
filterName
,
{
apply
:
function
(
)
{
applyCallbackResult
=
0
;
}
,
check
:
function
(
)
{
return
NodeGit
.
Error
.
CODE
.
OK
;
}
}
,
0
)
;
}
)
.
then
(
function
(
result
)
{
assert
.
strictEqual
(
result
,
NodeGit
.
Error
.
CODE
.
OK
)
;
return
loopingCheckoutHead
(
clonePath
,
repository
,
10
)
;
}
)
.
then
(
function
(
)
{
assert
.
strictEqual
(
applyCallbackResult
,
0
)
;
// Tracked objects must work too when the Garbage Collector is triggered
garbageCollect
(
)
;
// Count total of objects left after being created/destroyed
const
freeingCount
=
NodeGit
.
Cert
.
getNonSelfFreeingConstructedCount
(
)
+
NodeGit
.
FilterSource
.
getNonSelfFreeingConstructedCount
(
)
+
NodeGit
.
Buf
.
getNonSelfFreeingConstructedCount
(
)
+
NodeGit
.
Repository
.
getSelfFreeingInstanceCount
(
)
;
const
numberOfTrackedObjects
=
NodeGit
.
getNumberOfTrackedObjects
(
)
;
if
(
freeingCount
===
numberOfTrackedObjects
)
{
parentPort
.
postMessage
(
"numbersMatch"
)
;
}
else
{
parentPort
.
postMessage
(
"numbersDoNotMatch"
)
;
}
return
promisify
(
setTimeout
)
(
50000
)
;
}
)
.
catch
(
(
err
)
=>
parentPort
.
postMessage
(
"failure"
)
)
;
Back
|
FazBrowse Home
|
New Git URL