-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathreview.groovy
65 lines (58 loc) · 1.65 KB
/
review.groovy
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
import com.google.gerrit.sshd.SshCommand
import com.google.gerrit.sshd.CommandMetaData
import com.google.gerrit.extensions.annotations.Export
import com.google.gerrit.extensions.api.GerritApi
import com.google.gerrit.extensions.api.changes.ReviewInput
import com.google.inject.Inject
import org.kohsuke.args4j.Argument
class Review extends SshCommand {
@Inject GerritApi gApi
@Argument(usage = "change id", metaVar = "CHANGE")
String change
void run(){}
}
@Export("recommend")
@CommandMetaData(name = "recommend", description = "Vote +1 on Code-Review")
class Recommend extends Review {
void run() {
stdout.println("Recommend change: " + change)
gApi.changes()
.id(change)
.current()
.review(ReviewInput.recommend())
}
}
@Export("dislike")
@CommandMetaData(name = "dislike", description = "Vote -1 on Code-Review")
class Dislike extends Review {
void run() {
stdout.println("Dislike change: " + change)
gApi.changes()
.id(change)
.current()
.review(ReviewInput.dislike())
}
}
@Export("approve")
@CommandMetaData(name = "approve", description = "Vote +2 on Code-Review")
class Approve extends Review {
void run() {
stdout.println("Approve change: " + change)
gApi.changes()
.id(change)
.current()
.review(ReviewInput.approve())
}
}
@Export("reject")
@CommandMetaData(name = "reject", description = "Vote -2 on Code-Review")
class Reject extends Review {
void run() {
stdout.println("Reject change: " + change)
gApi.changes()
.id(change)
.current()
.review(ReviewInput.reject())
}
}
commands = [ Recommend, Dislike, Approve, Reject ]