FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nodegit/test/utils/worker_context_aware.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.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
74 lines (62 loc) · 1.98 KB
Breadcrumbs
nodegit
/
test
/
utils
/
worker_context_aware.js
Copy path
File metadata and controls
74 lines (62 loc) · 1.98 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
const
{
isMainThread
,
parentPort
,
workerData
}
=
require
(
"worker_threads"
)
;
const
garbageCollect
=
require
(
"./garbage_collect.js"
)
;
const
assert
=
require
(
"assert"
)
;
const
NodeGit
=
require
(
"../../"
)
;
const
{
promisify
}
=
require
(
"util"
)
;
if
(
isMainThread
)
{
throw
new
Error
(
"Must be run via worker thread"
)
;
}
const
{
clonePath
,
url
}
=
workerData
;
const
opts
=
{
fetchOpts
:
{
callbacks
:
{
certificateCheck
:
(
)
=>
0
}
}
}
;
let
repository
;
const
oid
=
"fce88902e66c72b5b93e75bdb5ae717038b221f6"
;
return
NodeGit
.
Clone
(
url
,
clonePath
,
opts
)
.
then
(
(
_repository
)
=>
{
repository
=
_repository
;
assert
.
ok
(
repository
instanceof
NodeGit
.
Repository
)
;
return
repository
.
getCommit
(
oid
)
;
}
)
.
then
(
(
commit
)
=>
{
assert
.
ok
(
commit
instanceof
NodeGit
.
Commit
)
;
var
historyCount
=
0
;
var
history
=
commit
.
history
(
)
;
history
.
on
(
"commit"
,
function
(
commit
)
{
// Number of commits is known to be higher than 200
if
(
++
historyCount
==
200
)
{
// 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
.
Repository
.
getSelfFreeingInstanceCount
(
)
+
NodeGit
.
Commit
.
getSelfFreeingInstanceCount
(
)
+
NodeGit
.
Oid
.
getSelfFreeingInstanceCount
(
)
+
NodeGit
.
Revwalk
.
getSelfFreeingInstanceCount
(
)
;
const
numberOfTrackedObjects
=
NodeGit
.
getNumberOfTrackedObjects
(
)
;
if
(
freeingCount
===
numberOfTrackedObjects
)
{
parentPort
.
postMessage
(
"numbersMatch"
)
;
}
else
{
parentPort
.
postMessage
(
"numbersDoNotMatch"
)
;
}
}
}
)
;
history
.
on
(
"end"
,
function
(
commits
)
{
// Test should not get this far
parentPort
.
postMessage
(
"failure"
)
;
}
)
;
history
.
on
(
"error"
,
function
(
err
)
{
assert
.
ok
(
false
)
;
}
)
;
history
.
start
(
)
;
return
promisify
(
setTimeout
)
(
50000
)
;
}
)
.
catch
(
(
)
=>
parentPort
.
postMessage
(
"failure"
)
)
;
Back
|
FazBrowse Home
|
New Git URL