lita-github_pr_list 0.0.16 → 0.0.19

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cdf9713e32606d90c856f4cfa8e76dce822eaa6f
4
- data.tar.gz: 08cb5fb6c22cb47f1e9d6df233d544088a5b14ac
3
+ metadata.gz: 4ac2c61fa0c996d2927dcbfb5b2da7035fbe3565
4
+ data.tar.gz: 2cfb0f5046eed5f37ab7cd9980c47d78fba60824
5
5
  SHA512:
6
- metadata.gz: 1bdbac47ac8daeefa1e75e3c384369039346a0b0a90c7d1e6efe594aa4f29ff0f7d74422ff0c1ca4c0b530a4b3a09ceb7cb558f17c472a06df5d57c552d2cc06
7
- data.tar.gz: 853e48b9c0d629a983acfc14d6b9afdcf8133f4e58a724451acc376a934e9d04ac03880fa2db3538d1f7bc9efe28097117dbfcc814f760189d849e69930d9c93
6
+ metadata.gz: 1084cb4cb0b99d178ad64dfc5876a17dd80f513e8dd77e8a856dcd61f1ebd4301e3e987ff1c12280d7b2f0310c86d0f353034c23efc2ad7e60cfabcc911d1c48
7
+ data.tar.gz: 348be2dd911a8d157fc05f6e3f1e7c503346bfb8a9f7e4fd5bdb68429e56a4cab1ed07b1b8c0c89b4a652a599d528be4e5aab91f1d6fd130d5332c432aba53bf
data/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ## 2015-04-15
2
+
3
+ Bug Fixes:
4
+
5
+ * Incrementing gem version, as rubygems doesn't let you push old versions. ([#37][], [@MathieuGilbert][])
6
+
7
+ ## 2015-04-14
8
+
9
+ Bug Fixes:
10
+
11
+ * Updating syntax on Lita.adapters to match Lita 5 syntax (now used in main Lita app). ([#35][], [@MathieuGilbert][])
12
+
13
+ ## 2015-04-10
14
+
15
+ Features:
16
+
17
+ * Querying Gitlab's API for a list of merge requests when "pr list" command is made, to clear out the merge events we didn't get a webhook call for. ([#33][], [@MathieuGilbert][])
18
+
1
19
  ## 2014-11-04
2
20
 
3
21
  Bug Fixes:
@@ -28,6 +46,9 @@ Features:
28
46
  [#29]: https://github.com/amaabca/lita-github_pr_list/issues/29
29
47
  [#30]: https://github.com/amaabca/lita-github_pr_list/issues/30
30
48
  [#32]: https://github.com/amaabca/lita-github_pr_list/issues/32
49
+ [#33]: https://github.com/amaabca/lita-github_pr_list/issues/33
50
+ [#35]: https://github.com/amaabca/lita-github_pr_list/issues/35
51
+ [#37]: https://github.com/amaabca/lita-github_pr_list/issues/37
31
52
  [@MathieuGilbert]: https://github.com/MathieuGilbert
32
53
  [@darkodosenovic]: https://github.com/darkodosenovic
33
54
  [@rubene]: https://github.com/rubene
@@ -0,0 +1,19 @@
1
+ module Builders
2
+ class MergeRequestBuilder
3
+ attr_accessor :merge_request_data
4
+
5
+ def initialize(args = {})
6
+ self.merge_request_data = args.fetch(:merge_request_data, [])
7
+ end
8
+
9
+ def all
10
+ merge_request_data.map do |m|
11
+ OpenStruct.new(id: m["id"], state: m["state"])
12
+ end
13
+ end
14
+
15
+ def closed
16
+ all.select { |m| m.state.downcase != 'opened' }
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,45 @@
1
+ require 'rest_client'
2
+
3
+ module Lita
4
+ module GithubPrList
5
+ class GitlabMergeRequests
6
+ attr_accessor :raw_response, :redis
7
+
8
+ def initialize(args = {})
9
+ self.redis = args.fetch(:redis, nil)
10
+ end
11
+
12
+ # Gitlab merge events don't always trigger the web hook. This will remove merged MRs from redis
13
+ def rectify
14
+ if local_merge_requests?
15
+ closed_merge_requests.each do |closed_merge_request|
16
+ Lita::GithubPrList::MergeRequest.new({ id: closed_merge_request.id, state: 'not_open', redis: redis }).handle
17
+ end
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def gitlab_data
24
+ self.raw_response = RestClient::Request.execute(
25
+ method: :get,
26
+ url: "#{Lita.config.handlers.github_pr_list.gitlab_project_endpoint}/merge_requests",
27
+ headers: {
28
+ accept: 'application/xml',
29
+ content_type: 'application/xml',
30
+ 'PRIVATE-TOKEN' => Lita.config.handlers.github_pr_list.gitlab_api_key
31
+ },
32
+ verify_ssl: OpenSSL::SSL::VERIFY_NONE
33
+ )
34
+ end
35
+
36
+ def closed_merge_requests
37
+ Builders::MergeRequestBuilder.new(merge_request_data: JSON.parse(gitlab_data)).closed
38
+ end
39
+
40
+ def local_merge_requests?
41
+ redis.keys("gitlab_mr*").any?
42
+ end
43
+ end
44
+ end
45
+ end
@@ -1,5 +1,5 @@
1
1
  module Lita
2
2
  module GithubPrList
3
- VERSION = "0.0.16"
3
+ VERSION = "0.0.19"
4
4
  end
5
5
  end
@@ -0,0 +1,68 @@
1
+ [
2
+ {
3
+ "id": 41,
4
+ "iid": 41,
5
+ "project_id": 1,
6
+ "target_branch": "master",
7
+ "source_branch": "api-unicorns",
8
+ "title": "Api Unicorns",
9
+ "state": "merged",
10
+ "upvotes": 0,
11
+ "downvotes": 0,
12
+ "author": {
13
+ "id": 6,
14
+ "username": "mathieu.gilbert",
15
+ "email": "mathieu.gilbert@ama.ab.ca",
16
+ "name": "Mathieu Gilbert",
17
+ "state": "active",
18
+ "created_at": "2014-01-16T21:23:07.474Z"
19
+ },
20
+ "assignee": null,
21
+ "source_project_id": 1,
22
+ "target_project_id": 1
23
+ },
24
+ {
25
+ "id": 3,
26
+ "iid": 3,
27
+ "project_id": 1,
28
+ "target_branch": "master",
29
+ "source_branch": "remote-syslog-on-db-servers",
30
+ "title": "Remote Syslog On Db Servers",
31
+ "state": "closed",
32
+ "upvotes": 0,
33
+ "downvotes": 0,
34
+ "author": {
35
+ "id": 5,
36
+ "username": "jordan.babe",
37
+ "email": "jordan.babe@ama.ab.ca",
38
+ "name": "Jordan Babe",
39
+ "state": "active",
40
+ "created_at": "2014-01-16T21:22:31.114Z"
41
+ },
42
+ "assignee": null,
43
+ "source_project_id": 1,
44
+ "target_project_id": 1
45
+ },
46
+ {
47
+ "id": 99,
48
+ "iid": 1,
49
+ "project_id": 14,
50
+ "target_branch": "master",
51
+ "source_branch": "pie-factory",
52
+ "title": "Fixed the things",
53
+ "state": "opened",
54
+ "upvotes": 0,
55
+ "downvotes": 0,
56
+ "author": {
57
+ "id": 5,
58
+ "username": "jordan.babe",
59
+ "email": "jordan.babe@ama.ab.ca",
60
+ "name": "Jordan Babe",
61
+ "state": "active",
62
+ "created_at": "2014-01-16T21:22:31.114Z"
63
+ },
64
+ "assignee": null,
65
+ "source_project_id": 1,
66
+ "target_project_id": 1
67
+ }
68
+ ]
@@ -0,0 +1,22 @@
1
+ {
2
+ "object_kind": "merge_request",
3
+ "object_attributes": {
4
+ "assignee_id": 6,
5
+ "author_id": 51,
6
+ "created_at": "2013-12-03T17:23:34Z",
7
+ "description": "",
8
+ "id": 3,
9
+ "iid": 1,
10
+ "merge_status": "unchecked",
11
+ "milestone_id": null,
12
+ "source_branch": "ms-viewport",
13
+ "source_project_id": 14,
14
+ "st_commits": null,
15
+ "st_diffs": null,
16
+ "state": "opened",
17
+ "target_branch": "master",
18
+ "target_project_id": 14,
19
+ "title": "Fixed the things",
20
+ "updated_at": "2013-12-03T17:23:34Z"
21
+ }
22
+ }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-github_pr_list
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael van den Beuken
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2014-11-04 00:00:00.000000000 Z
16
+ date: 2015-04-15 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: lita
@@ -166,10 +166,12 @@ files:
166
166
  - Rakefile
167
167
  - bin/rake
168
168
  - bin/rspec
169
+ - lib/lita/builders/merge_request_builder.rb
169
170
  - lib/lita/github_pr_list.rb
170
171
  - lib/lita/github_pr_list/alias_user.rb
171
172
  - lib/lita/github_pr_list/check_list.rb
172
173
  - lib/lita/github_pr_list/comment_hook.rb
174
+ - lib/lita/github_pr_list/gitlab_merge_requests.rb
173
175
  - lib/lita/github_pr_list/merge_request.rb
174
176
  - lib/lita/github_pr_list/pull_request.rb
175
177
  - lib/lita/github_pr_list/pull_request_open_message_hook.rb
@@ -178,7 +180,9 @@ files:
178
180
  - lib/lita/github_pr_list/web_hook.rb
179
181
  - lib/lita/handlers/github_pr_list.rb
180
182
  - lita-github_pr_list.gemspec
183
+ - spec/fixtures/gitlab_lookup_response.json
181
184
  - spec/fixtures/gitlab_merge_request.json
185
+ - spec/fixtures/gitlab_remotely_closed.json
182
186
  - spec/fixtures/gitlab_request_closed.json
183
187
  - spec/fixtures/issue_comment_event_failed.json
184
188
  - spec/fixtures/issue_comment_event_failed_hankey.json
@@ -224,12 +228,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
224
228
  version: '0'
225
229
  requirements: []
226
230
  rubyforge_project:
227
- rubygems_version: 2.0.0
231
+ rubygems_version: 2.0.14
228
232
  signing_key:
229
233
  specification_version: 4
230
234
  summary: List open pull requests for an organization.
231
235
  test_files:
236
+ - spec/fixtures/gitlab_lookup_response.json
232
237
  - spec/fixtures/gitlab_merge_request.json
238
+ - spec/fixtures/gitlab_remotely_closed.json
233
239
  - spec/fixtures/gitlab_request_closed.json
234
240
  - spec/fixtures/issue_comment_event_failed.json
235
241
  - spec/fixtures/issue_comment_event_failed_hankey.json