-
Notifications
You must be signed in to change notification settings - Fork 3
/
Revwalk.pm6
123 lines (98 loc) · 3.33 KB
/
Revwalk.pm6
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
use NativeCall;
use Git::Error;
use Git::Oid;
subset Git::Glob of Str where /<[*?\[]>/;
subset Git::Range of Str where /'..'/;
enum Git::Sort
(
GIT_SORT_NONE => 0,
GIT_SORT_TOPOLOGICAL => 1 +< 0,
GIT_SORT_TIME => 1 +< 1,
GIT_SORT_REVERSE => 1 +< 2,
);
class Git::Revwalk is repr('CPointer') {...}
class Git::Revwalk::Iterator does Iterator
{
has Git::Revwalk $.revwalk;
has Git::Oid $.oid = Git::Oid.new;
sub git_revwalk_next(Git::Oid, Git::Revwalk --> int32)
is native('git2') {}
method pull-one
{
my $ret = git_revwalk_next($!oid, $!revwalk);
return IterationEnd if $ret == GIT_ITEROVER;
check($ret);
$!oid
}
}
class Git::Revwalk
{
sub git_revwalk_free(Git::Revwalk)
is native('git2') {}
sub git_revwalk_hide(Git::Revwalk, Git::Oid --> int32)
is native('git2') {}
sub git_revwalk_hide_glob(Git::Revwalk, Str --> int32)
is native('git2') {}
sub git_revwalk_hide_ref(Git::Revwalk, Str --> int32)
is native('git2') {}
method hide(*@args)
{
for @args
{
when Git::Oid { check(git_revwalk_hide(self, $_)) }
when Git::Oidlike { check(git_revwalk_hide(self, Git::Oid.new($_))) }
when Git::Glob { check(git_revwalk_hide_glob(self, $_)) }
default { check(git_revwalk_hide_ref(self, $_)) }
}
self
}
sub git_revwalk_push(Git::Revwalk, Git::Oid --> int32)
is native('git2') {}
sub git_revwalk_push_ref(Git::Revwalk, Str --> int32)
is native('git2') {}
sub git_revwalk_push_glob(Git::Revwalk, Str --> int32)
is native('git2') {}
sub git_revwalk_push_range(Git::Revwalk, Str --> int32)
is native('git2') {}
method push(*@args)
{
for @args
{
when Git::Oid { check(git_revwalk_push(self, $_)) }
when Git::Oidlike { check(git_revwalk_push(self, Git::Oid.new($_))) }
when Git::Glob { check(git_revwalk_push_glob($_)) }
when Git::Range { check(git_revwalk_push_range(self, $_)) }
default { check(git_revwalk_push_ref(self, $_)) }
}
self
}
method simplify-first-parent()
is native('git2') is symbol('git_revwalk_simplify_first_parent') {}
sub git_revwalk_sorting(Git::Revwalk, uint32)
is native('git2') {}
method sorting(Bool :$topological, Bool :$time, Bool :$reverse)
{
my uint32 $sorting =
($topological ?? GIT_SORT_TOPOLOGICAL !! 0)
+| ($time ?? GIT_SORT_TIME !! 0)
+| ($reverse ?? GIT_SORT_REVERSE !! 0);
git_revwalk_sorting(self, $sorting);
self
}
method reset()
is native('git2') is symbol('git_revwalk_reset') {}
sub git_revwalk_repository(Git::Revwalk --> Pointer)
is native('git2') {}
method repository()
{
nativecast(::('Git::Repository'), git_revwalk_repository(self))
}
method walk(:$push, :$hide, Bool :$simplify-first-parent)
{
self.push(|$push) if $push;
self.hide(|$hide) if $hide;
self.simplify-first-parent if $simplify-first-parent;
Seq.new(Git::Revwalk::Iterator.new(revwalk => self))
}
submethod DESTROY { git_revwalk_free(self) }
}