FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nodegit.nodegit/lib/revwalk.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
/
lib
/
revwalk.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
114 lines (93 loc) · 2.42 KB
Breadcrumbs
nodegit.nodegit
/
lib
/
revwalk.js
Copy path
File metadata and controls
114 lines (93 loc) · 2.42 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
var
NodeGit
=
require
(
"../"
)
;
var
Revwalk
=
NodeGit
.
Revwalk
;
var
Promise
=
require
(
"nodegit-promise"
)
;
var
oldSorting
=
Revwalk
.
prototype
.
sorting
;
/**
* Set the sort order for the revwalk. This function takes variable arguments
* like `revwalk.sorting(NodeGit.RevWalk.Topological, NodeGit.RevWalk.Reverse).`
*
*
@param
{
Number
} sort
*/
Revwalk
.
prototype
.
sorting
=
function
(
)
{
var
sort
=
0
;
for
(
var
i
=
0
;
i
<
arguments
.
length
;
i
++
)
{
sort
|=
arguments
[
i
]
;
}
oldSorting
.
call
(
this
,
sort
)
;
}
;
/**
* Walk the history from the given oid. The callback is invoked for each commit;
* When the walk is over, the callback is invoked with `(null, null)`.
*
*
@param
{
Oid
} oid
*
@param
{
Function
} callback
*
@return
{
Commit
}
*/
Revwalk
.
prototype
.
walk
=
function
(
oid
,
callback
)
{
var
revwalk
=
this
;
this
.
push
(
oid
)
;
function
walk
(
)
{
revwalk
.
next
(
)
.
then
(
function
(
oid
)
{
if
(
!
oid
)
{
if
(
typeof
callback
===
"function"
)
{
return
callback
(
)
;
}
return
;
}
revwalk
.
repo
.
getCommit
(
oid
)
.
then
(
function
(
commit
)
{
if
(
typeof
callback
===
"function"
)
{
callback
(
null
,
commit
)
;
}
walk
(
)
;
}
)
;
}
,
callback
)
;
}
walk
(
)
;
}
;
/**
* Walk the history grabbing commits until the checkFn called with the
* current commit returns false.
*
*
@param
{
Function
} checkFn function returns false to stop walking
*
@return
{
Array
}
*/
Revwalk
.
prototype
.
getCommitsUntil
=
function
(
checkFn
)
{
var
commits
=
[
]
;
var
walker
=
this
;
function
walkCommitsCb
(
)
{
return
walker
.
next
(
)
.
then
(
function
(
oid
)
{
if
(
!
oid
)
{
return
;
}
return
walker
.
repo
.
getCommit
(
oid
)
.
then
(
function
(
commit
)
{
commits
.
push
(
commit
)
;
if
(
checkFn
(
commit
)
)
{
return
walkCommitsCb
(
)
;
}
}
)
;
}
)
;
}
return
walkCommitsCb
(
)
.
then
(
function
(
)
{
return
commits
;
}
)
;
}
;
/**
* Get a number of commits.
*
*
@param
{
Number
} count (default: 10)
*
@return
{
Array<Commit>
}
*/
Revwalk
.
prototype
.
getCommits
=
function
(
count
)
{
count
=
count
||
10
;
var
promises
=
[
]
;
var
walker
=
this
;
function
walkCommitsCount
(
count
)
{
if
(
count
===
0
)
{
return
;
}
return
walker
.
next
(
)
.
then
(
function
(
oid
)
{
if
(
!
oid
)
{
return
;
}
promises
.
push
(
walker
.
repo
.
getCommit
(
oid
)
)
;
return
walkCommitsCount
(
count
-
1
)
;
}
)
;
}
return
walkCommitsCount
(
count
)
.
then
(
function
(
)
{
return
Promise
.
all
(
promises
)
;
}
)
;
}
;
Back
|
FazBrowse Home
|
New Git URL