lita-pullrequests 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -3
- data/lib/lita/handlers/pullrequests.rb +21 -13
- data/lita-pullrequests.gemspec +2 -2
- data/spec/lita/handlers/pullrequests_spec.rb +9 -5
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7dd56dc1fe66435afb8b441ba37c57c22350d4bf
|
4
|
+
data.tar.gz: aecf5c8c58d4c5b6506b143cda912d3d28aa1e81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d243ebc0217e6c7fd70dfcdd6e9bb1d7861027920ae287f14975b8823685f6fb9f46a9a6babbd8af549be54518952381c5ef95e983450a958b8338f0f3d219c6
|
7
|
+
data.tar.gz: bfae20e85f0ff5def1dcec42fa8a57cd5f95139b656e07d578aafebb3c76f7ff0af8ba53c5603b47cd16912b480357b888bed5ed1383a2d2b2e797220a65f34a
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# lita-pullrequests
|
2
2
|
|
3
|
-
A Lita handler to help you keep track of your pull requests.
|
3
|
+
A Lita handler to help you keep track of your pull requests. It can automatically post in your channels and tell you about which pull requests need attention in all of your repositories.
|
4
|
+
|
5
|
+
This means that you can mark some pull requests as needing attention, and your Lita bot will automatically know about them and remind you to address them whenever you tell it to.
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
@@ -16,7 +18,7 @@ Add the following configuration lines to your `lita_config`:
|
|
16
18
|
|
17
19
|
``` ruby
|
18
20
|
config.handlers.pullrequests.access_token = "a-github-api-access-token"
|
19
|
-
config.handlers.pullrequests.
|
21
|
+
config.handlers.pullrequests.repos = ["username/reponame"]
|
20
22
|
config.handlers.pullrequests.review_label = "title of a label that represents a pr ready for review"
|
21
23
|
config.handlers.pullrequests.merge_label = "title of a label that represents a pr ready for merge"
|
22
24
|
```
|
@@ -24,11 +26,20 @@ config.handlers.pullrequests.merge_label = "title of a label that represents a
|
|
24
26
|
## Usage
|
25
27
|
|
26
28
|
```
|
27
|
-
> @robot: give me something to review
|
29
|
+
> @robot: give me something to review for reponame
|
28
30
|
...
|
29
31
|
|
30
32
|
> @robot: summarize pull requests
|
31
33
|
....
|
34
|
+
|
35
|
+
> @robot: set pull requests reminder for 0 20 * * 1-5
|
36
|
+
....
|
37
|
+
|
38
|
+
> @robot: show pull requests reminder
|
39
|
+
....
|
40
|
+
|
41
|
+
> @robot: stop reminding me about pull requests
|
42
|
+
....
|
32
43
|
```
|
33
44
|
|
34
45
|
## License
|
@@ -4,7 +4,7 @@ module Lita
|
|
4
4
|
module Handlers
|
5
5
|
class Pullrequests < Handler
|
6
6
|
config :access_token, type: String, required: true
|
7
|
-
config :
|
7
|
+
config :repos, type: Array, required: true
|
8
8
|
config :review_label, type: String, required: false
|
9
9
|
config :merge_label, type: String, required: false
|
10
10
|
|
@@ -13,9 +13,8 @@ module Lita
|
|
13
13
|
SCHEDULER = Rufus::Scheduler.new
|
14
14
|
REDIS_KEY = "pullrequests-cron"
|
15
15
|
|
16
|
-
route(/^
|
17
|
-
"give me something to review" => "Shows you a random pull request that needs reviewing.",
|
18
|
-
"pull request (me)" => "Shows you a random pull request that needs reviewing."
|
16
|
+
route(/^give me something to review for (.*)$/, :get_random_pr, command: true, help: {
|
17
|
+
"give me something to review for REPO NAME" => "Shows you a random pull request that needs reviewing.",
|
19
18
|
})
|
20
19
|
|
21
20
|
route(/^(summarize|all) pull requests$/, :list_all_pull_requests, command: true, help: {
|
@@ -50,19 +49,28 @@ module Lita
|
|
50
49
|
end
|
51
50
|
|
52
51
|
def fetch_pull_requests
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
52
|
+
config.repos.map do |repo|
|
53
|
+
url = "https://api.github.com/repos/#{repo}/issues"
|
54
|
+
req = http.get(url, access_token: config.access_token)
|
55
|
+
issues = MultiJson.load(req.body)
|
56
|
+
issues.select { |issue| issue["pull_request"] }
|
57
|
+
end.flatten
|
57
58
|
end
|
58
59
|
|
59
60
|
def get_random_pr(chat)
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
61
|
+
pulls = pulls_that_need_reviews.group_by { |pr| pr["url"].split("/")[-3] }
|
62
|
+
repo = chat.matches[0][0]
|
63
|
+
|
64
|
+
if pulls[repo]
|
65
|
+
pr = pulls[repo].sample
|
66
|
+
if pr
|
67
|
+
title, user, url = pr["title"], pr["user"]["login"], pr["pull_request"]["html_url"]
|
68
|
+
chat.reply "_#{title}_ - #{user} \n #{url}"
|
69
|
+
else
|
70
|
+
chat.reply "No pull requests need reviews right now!"
|
71
|
+
end
|
64
72
|
else
|
65
|
-
chat.reply
|
73
|
+
chat.reply("I'm not configured for a repo with that name.")
|
66
74
|
end
|
67
75
|
end
|
68
76
|
|
data/lita-pullrequests.gemspec
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "lita-pullrequests"
|
3
|
-
spec.version = "0.0.
|
3
|
+
spec.version = "0.0.6"
|
4
4
|
spec.authors = ["Taylor Lapeyre"]
|
5
5
|
spec.email = ["taylorlapeyre@gmail.com"]
|
6
6
|
spec.description = %q{A Lita handler to help you keep track of your pull requests.}
|
7
|
-
spec.summary = %q{A Lita handler to help you keep track of your pull requests.}
|
7
|
+
spec.summary = %q{A Lita handler to help you keep track of your pull requests. It can automatically post in your channels and tell you about which pull requests need attention.}
|
8
8
|
spec.homepage = "https://github.com/taylorlapeyre/lita-pullrequests"
|
9
9
|
spec.license = "MIT"
|
10
10
|
spec.metadata = { "lita_plugin_type" => "handler" }
|
@@ -3,14 +3,12 @@ require "spec_helper"
|
|
3
3
|
describe Lita::Handlers::Pullrequests, lita_handler: true do
|
4
4
|
before do
|
5
5
|
Lita.config.handlers.pullrequests.access_token = ENV["GITHUB_ACCESS_TOKEN"]
|
6
|
-
Lita.config.handlers.pullrequests.
|
6
|
+
Lita.config.handlers.pullrequests.repos = ["taylorlapeyre/lita-pullrequests"]
|
7
7
|
Lita.config.handlers.pullrequests.review_label = "Needs Review"
|
8
8
|
Lita.config.handlers.pullrequests.merge_label = "Ready To Merge"
|
9
9
|
end
|
10
10
|
|
11
|
-
it { is_expected.to route_command("
|
12
|
-
it { is_expected.to route_command("pull request me").to(:get_random_pr) }
|
13
|
-
it { is_expected.to route_command("give me something to review").to(:get_random_pr) }
|
11
|
+
it { is_expected.to route_command("give me something to review for lita-pullrequests").to(:get_random_pr) }
|
14
12
|
it { is_expected.to route_command("all pull requests").to(:list_all_pull_requests) }
|
15
13
|
it { is_expected.to route_command("summarize pull requests").to(:list_all_pull_requests) }
|
16
14
|
it { is_expected.to route_command("set pull requests reminder for 0 20 * * 1-5").to(:set_reminder) }
|
@@ -22,11 +20,17 @@ describe Lita::Handlers::Pullrequests, lita_handler: true do
|
|
22
20
|
it { is_expected.to_not route_command("all pull requests").to(:get_random_pr) }
|
23
21
|
|
24
22
|
it "can respond with a random pull request" do
|
25
|
-
send_command("give me something to review")
|
23
|
+
send_command("give me something to review for lita-pullrequests")
|
26
24
|
expect(replies).to_not be_empty
|
27
25
|
expect(replies.last).to match /Example of a pull request ready for review/
|
28
26
|
end
|
29
27
|
|
28
|
+
it "knows when you asked for a repo that it doesn't know about." do
|
29
|
+
send_command("give me something to review for foobar")
|
30
|
+
expect(replies).to_not be_empty
|
31
|
+
expect(replies.last).to eq "I'm not configured for a repo with that name."
|
32
|
+
end
|
33
|
+
|
30
34
|
it "can respond with all pull requests" do
|
31
35
|
send_command("summarize pull requests")
|
32
36
|
expect(replies).to_not be_empty
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-pullrequests
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taylor Lapeyre
|
@@ -136,7 +136,8 @@ rubyforge_project:
|
|
136
136
|
rubygems_version: 2.4.5
|
137
137
|
signing_key:
|
138
138
|
specification_version: 4
|
139
|
-
summary: A Lita handler to help you keep track of your pull requests.
|
139
|
+
summary: A Lita handler to help you keep track of your pull requests. It can automatically
|
140
|
+
post in your channels and tell you about which pull requests need attention.
|
140
141
|
test_files:
|
141
142
|
- spec/lita/handlers/pullrequests_spec.rb
|
142
143
|
- spec/spec_helper.rb
|