lita-github 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +34 -0
- data/.rspec +2 -0
- data/.rubocop.yml +14 -0
- data/.travis.yml +10 -0
- data/Gemfile +19 -0
- data/Gemfile.lock +113 -0
- data/LICENSE +176 -0
- data/README.md +41 -0
- data/Rakefile +28 -0
- data/lib/lita-github.rb +24 -0
- data/lib/lita-github/config.rb +24 -0
- data/lib/lita-github/octo.rb +37 -0
- data/lib/lita-github/r.rb +30 -0
- data/lib/lita-github/version.rb +21 -0
- data/lib/lita/handlers/github.rb +68 -0
- data/lita-github.gemspec +49 -0
- data/locales/en.yml +23 -0
- data/spec/spec_helper.rb +27 -0
- data/spec/unit/lita-github/config_spec.rb +30 -0
- data/spec/unit/lita-github/octo_spec.rb +53 -0
- data/spec/unit/lita-github/r_spec.rb +93 -0
- data/spec/unit/lita-github/version_spec.rb +41 -0
- data/spec/unit/lita/handlers/github_spec.rb +104 -0
- metadata +214 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dc3526e11e2ee29500e53d039037b006f74137b9
|
4
|
+
data.tar.gz: f66a2729e9335198069b8b88fa45e46d3cfb57f7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0404f2c6e7846c9ae078809738d894c0a18a4a5ddb134c8e1626abd84c3a2c2cd1459ae91599e458cee909e3ec4d385d57226dd32280bcbf764351267f29092a
|
7
|
+
data.tar.gz: a2bc91f92334ae48fc92c630903eb5edbeecc06b63a7c2534722bc94f3c7b6b0b3c453d3e2e9e3c94bc5ad0d46e830d17cfdae6f84c51ec5efa0b19dceda25f7
|
data/.gitignore
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/lib/bundler/man/
|
26
|
+
|
27
|
+
# for a library or gem, you might want to ignore these files since the code is
|
28
|
+
# intended to run in multiple environments; otherwise, check them in:
|
29
|
+
# Gemfile.lock
|
30
|
+
# .ruby-version
|
31
|
+
# .ruby-gemset
|
32
|
+
|
33
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
34
|
+
.rvmrc
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright 2014 PagerDuty, Inc.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
source 'https://rubygems.org'
|
18
|
+
|
19
|
+
gemspec
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
lita-github (0.0.1)
|
5
|
+
lita (~> 3.3)
|
6
|
+
lita-confirmation
|
7
|
+
octokit (~> 3.3)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
addressable (2.3.6)
|
13
|
+
ast (2.0.0)
|
14
|
+
coveralls (0.7.0)
|
15
|
+
multi_json (~> 1.3)
|
16
|
+
rest-client
|
17
|
+
simplecov (>= 0.7)
|
18
|
+
term-ansicolor
|
19
|
+
thor
|
20
|
+
diff-lcs (1.2.5)
|
21
|
+
docile (1.1.5)
|
22
|
+
faraday (0.9.0)
|
23
|
+
multipart-post (>= 1.2, < 3)
|
24
|
+
fuubar (2.0.0)
|
25
|
+
rspec (~> 3.0)
|
26
|
+
ruby-progressbar (~> 1.4)
|
27
|
+
http_router (0.11.1)
|
28
|
+
rack (>= 1.0.0)
|
29
|
+
url_mount (~> 0.2.1)
|
30
|
+
i18n (0.6.11)
|
31
|
+
ice_nine (0.11.0)
|
32
|
+
lita (3.3.1)
|
33
|
+
bundler (>= 1.3)
|
34
|
+
faraday (>= 0.8.7)
|
35
|
+
http_router (>= 0.11.1)
|
36
|
+
i18n (>= 0.6.9)
|
37
|
+
ice_nine (>= 0.11.0)
|
38
|
+
multi_json (>= 1.7.7)
|
39
|
+
puma (>= 2.7.1)
|
40
|
+
rack (>= 1.5.2)
|
41
|
+
rb-readline (>= 0.5.1)
|
42
|
+
redis-namespace (>= 1.3.0)
|
43
|
+
thor (>= 0.18.1)
|
44
|
+
lita-confirmation (0.0.1)
|
45
|
+
lita (>= 3.3)
|
46
|
+
mime-types (2.3)
|
47
|
+
multi_json (1.10.1)
|
48
|
+
multipart-post (2.0.0)
|
49
|
+
netrc (0.7.7)
|
50
|
+
octokit (3.3.1)
|
51
|
+
sawyer (~> 0.5.3)
|
52
|
+
parser (2.2.0.pre.4)
|
53
|
+
ast (>= 1.1, < 3.0)
|
54
|
+
slop (~> 3.4, >= 3.4.5)
|
55
|
+
powerpack (0.0.9)
|
56
|
+
puma (2.9.0)
|
57
|
+
rack (>= 1.1, < 2.0)
|
58
|
+
rack (1.5.2)
|
59
|
+
rainbow (2.0.0)
|
60
|
+
rake (10.3.2)
|
61
|
+
rb-readline (0.5.1)
|
62
|
+
redis (3.1.0)
|
63
|
+
redis-namespace (1.5.1)
|
64
|
+
redis (~> 3.0, >= 3.0.4)
|
65
|
+
rest-client (1.7.2)
|
66
|
+
mime-types (>= 1.16, < 3.0)
|
67
|
+
netrc (~> 0.7)
|
68
|
+
rspec (3.0.0)
|
69
|
+
rspec-core (~> 3.0.0)
|
70
|
+
rspec-expectations (~> 3.0.0)
|
71
|
+
rspec-mocks (~> 3.0.0)
|
72
|
+
rspec-core (3.0.4)
|
73
|
+
rspec-support (~> 3.0.0)
|
74
|
+
rspec-expectations (3.0.4)
|
75
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
76
|
+
rspec-support (~> 3.0.0)
|
77
|
+
rspec-mocks (3.0.4)
|
78
|
+
rspec-support (~> 3.0.0)
|
79
|
+
rspec-support (3.0.4)
|
80
|
+
rubocop (0.25.0)
|
81
|
+
parser (>= 2.2.0.pre.4, < 3.0)
|
82
|
+
powerpack (~> 0.0.6)
|
83
|
+
rainbow (>= 1.99.1, < 3.0)
|
84
|
+
ruby-progressbar (~> 1.4)
|
85
|
+
ruby-progressbar (1.5.1)
|
86
|
+
sawyer (0.5.5)
|
87
|
+
addressable (~> 2.3.5)
|
88
|
+
faraday (~> 0.8, < 0.10)
|
89
|
+
simplecov (0.9.0)
|
90
|
+
docile (~> 1.1.0)
|
91
|
+
multi_json
|
92
|
+
simplecov-html (~> 0.8.0)
|
93
|
+
simplecov-html (0.8.0)
|
94
|
+
slop (3.6.0)
|
95
|
+
term-ansicolor (1.3.0)
|
96
|
+
tins (~> 1.0)
|
97
|
+
thor (0.19.1)
|
98
|
+
tins (1.3.0)
|
99
|
+
url_mount (0.2.1)
|
100
|
+
rack
|
101
|
+
|
102
|
+
PLATFORMS
|
103
|
+
ruby
|
104
|
+
|
105
|
+
DEPENDENCIES
|
106
|
+
bundler (~> 1.5)
|
107
|
+
coveralls (~> 0.7)
|
108
|
+
fuubar (~> 2.0)
|
109
|
+
lita-github!
|
110
|
+
rake (~> 10.2)
|
111
|
+
rspec (~> 3.0)
|
112
|
+
rubocop (~> 0.25.0)
|
113
|
+
simplecov (~> 0.9)
|
data/LICENSE
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
lita-github
|
2
|
+
===========
|
3
|
+
Copyright 2014 PagerDuty, Inc.
|
4
|
+
|
5
|
+
Lita handler for GitHub-related operations. This include administrative management of organizations and repository management/operations.
|
6
|
+
|
7
|
+
This project was born out of the Aug 22, 2014 HackDay at PagerDuty.
|
8
|
+
|
9
|
+
Under Development
|
10
|
+
-----------------
|
11
|
+
This Gem is currently in development, and is not suited for production use. There will probably be bugs.
|
12
|
+
|
13
|
+
In addition, the documentation will be lacking while the development is underway.
|
14
|
+
|
15
|
+
Configuration
|
16
|
+
-------------
|
17
|
+
The configuration options will get their own in-depth doc a little further down the line. Here are the important ones for now:
|
18
|
+
|
19
|
+
* `config.handlers.github.access_token = ''`
|
20
|
+
* Your GitHUb access token (generated from Settings > Security > Personal Applications)
|
21
|
+
* This is an administrative utility, so the token will need pretty wide access to leverage this plugin fully
|
22
|
+
* `config.handlers.default_org = ''`
|
23
|
+
* Your company may only have one organization, the handler will allow you to type just the repo name (`lita-github`) instead of `PagerDuty/lita-github`.
|
24
|
+
* `config.handlers.default_team_slug = ''`
|
25
|
+
* the default team that should be added to a repo based on the slug name:
|
26
|
+
* When clicking on a team in your org you can use the URL to get the slug: https://github.com/orgs/<ORG>/teams/[slug]
|
27
|
+
|
28
|
+
Commands
|
29
|
+
--------
|
30
|
+
Use the source, Luke. We will try to keep this list up to date, but it will be inevitably deprecated by proper documentation.
|
31
|
+
|
32
|
+
The command support two prefixes, assuming you have the `robot_alias` set to `!`:
|
33
|
+
* `!gh <command>`
|
34
|
+
* `!github <command>`
|
35
|
+
|
36
|
+
Here is the current functionality:
|
37
|
+
|
38
|
+
* `!gh status`
|
39
|
+
* get the current system status for GitHub
|
40
|
+
* `!gh version`
|
41
|
+
* get the version of handler
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- coding: UTF-8 -*_
|
2
|
+
#
|
3
|
+
# Copyright 2014 PagerDuty, Inc.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require 'rspec/core/rake_task'
|
18
|
+
require 'rubocop/rake_task'
|
19
|
+
|
20
|
+
RSpec::Core::RakeTask.new(:spec)
|
21
|
+
|
22
|
+
RuboCop::RakeTask.new(:rubocop) do |t|
|
23
|
+
t.patterns =
|
24
|
+
%w( Rakefile Gemfile lita-github.gemspec lib/**/*.rb spec/*_spec.rb )
|
25
|
+
t.fail_on_error = true
|
26
|
+
end
|
27
|
+
|
28
|
+
task default: [:rubocop, :spec]
|
data/lib/lita-github.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright 2014 PagerDuty, Inc.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require 'lita'
|
18
|
+
|
19
|
+
Lita.load_locales Dir[File.expand_path(
|
20
|
+
File.join('..', '..', 'locales', '*.yml'), __FILE__
|
21
|
+
)]
|
22
|
+
|
23
|
+
require 'lita-github/version'
|
24
|
+
require 'lita/handlers/github'
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright 2014 PagerDuty, Inc.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
module LitaGithub
|
18
|
+
# Github handler Lita configuration methods
|
19
|
+
module Config
|
20
|
+
def config
|
21
|
+
Lita.config.handlers.github
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright 2014 PagerDuty, Inc.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require 'octokit'
|
18
|
+
|
19
|
+
module LitaGithub
|
20
|
+
# Github handler common-use Octokit methods
|
21
|
+
module Octo
|
22
|
+
# pull the access token from the config
|
23
|
+
def access_token
|
24
|
+
config.access_token
|
25
|
+
end
|
26
|
+
|
27
|
+
# set up the Octokit client
|
28
|
+
def setup_octo(_)
|
29
|
+
@@octo ||= Octokit::Client.new(access_token: access_token)
|
30
|
+
end
|
31
|
+
|
32
|
+
# object access method for Octokit client
|
33
|
+
def octo
|
34
|
+
@@octo
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright 2014 PagerDuty, Inc.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
module LitaGithub
|
18
|
+
# Github handler common-use regex constants
|
19
|
+
module R
|
20
|
+
# command alias regex (!gh or !github for example)
|
21
|
+
A_REG ||= '(?:gh|github)\s+?'
|
22
|
+
|
23
|
+
# option regex, letting you scan the command string of things like:
|
24
|
+
# key1:value key2:value, etc.
|
25
|
+
OPT_REGEX ||= /((?:\s+?[a-zA-Z0-9_]+?):(?:[a-zA-Z0-9_]+))(?:\s+?)?/
|
26
|
+
|
27
|
+
# regex matcher for: Org/repo
|
28
|
+
REPO_REGEX = '(?:(?<org>\w+)(?:\s+?)?\/)?(?:\s+?)?(?<repo>\w+)'
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright 2014 PagerDuty, Inc.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
# Administer your Hub of Gits with Lita!
|
18
|
+
module LitaGithub
|
19
|
+
VERSION = '0.0.1'
|
20
|
+
MAJ, MIN, REV = VERSION.split('.').map(&:to_i)
|
21
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright 2014 PagerDuty, Inc.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require 'octokit'
|
18
|
+
require 'lita-github/version'
|
19
|
+
require 'lita-github/r'
|
20
|
+
require 'lita-github/config'
|
21
|
+
require 'lita-github/octo'
|
22
|
+
|
23
|
+
module Lita
|
24
|
+
# Lita Handler
|
25
|
+
module Handlers
|
26
|
+
# GitHub Lita Handler
|
27
|
+
class Github < Handler
|
28
|
+
include LitaGithub::R # Github handler common-use regex constants
|
29
|
+
include LitaGithub::Config # Github handler Lita configuration methods
|
30
|
+
include LitaGithub::Octo # Github handler common-use Octokit methods
|
31
|
+
|
32
|
+
on :loaded, :setup_octo # from LitaGithub::Octo
|
33
|
+
|
34
|
+
route(
|
35
|
+
/#{LitaGithub::R::A_REG}status/, :gh_status,
|
36
|
+
command: true,
|
37
|
+
help: {
|
38
|
+
'github status' => 'get the system status from GitHub',
|
39
|
+
'gh status' => 'get the system status from GitHub using short alias'
|
40
|
+
}
|
41
|
+
)
|
42
|
+
|
43
|
+
route(
|
44
|
+
/#{LitaGithub::R::A_REG}(?:v|version|build)/, :gh_version,
|
45
|
+
command: true,
|
46
|
+
help: {
|
47
|
+
'gh version' => 'get the lita-github version'
|
48
|
+
}
|
49
|
+
)
|
50
|
+
|
51
|
+
def self.default_config(config)
|
52
|
+
config.repo_delete_enabled = false
|
53
|
+
config.repo_private_default = true
|
54
|
+
end
|
55
|
+
|
56
|
+
def gh_status(response)
|
57
|
+
status = octo.github_status_last_message
|
58
|
+
response.reply(t("status.#{status[:status]}", status))
|
59
|
+
end
|
60
|
+
|
61
|
+
def gh_version(response)
|
62
|
+
response.reply("lita-github v#{LitaGithub::VERSION}")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
Lita.register_handler(Github)
|
67
|
+
end
|
68
|
+
end
|
data/lita-github.gemspec
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright 2014 PagerDuty, Inc.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
$LOAD_PATH.unshift(File.expand_path('../lib', __FILE__))
|
18
|
+
|
19
|
+
require 'lita-github/version'
|
20
|
+
|
21
|
+
Gem::Specification.new do |s|
|
22
|
+
s.name = 'lita-github'
|
23
|
+
s.summary = 'GitHub repo/org management in Lita; handler not ready for production'
|
24
|
+
s.author = 'Tim Heckman'
|
25
|
+
s.email = 'tim@pagerduty.com'
|
26
|
+
s.license = 'Apache 2.0'
|
27
|
+
s.version = LitaGithub::VERSION
|
28
|
+
s.date = Time.now.strftime('%Y-%m-%d')
|
29
|
+
s.homepage = 'https://github.com/PagerDuty/lita-github'
|
30
|
+
s.description = 'Lita handler for managing your GitHub account/organization; handler not ready for production'
|
31
|
+
|
32
|
+
s.test_files = `git ls-files spec/*`.split
|
33
|
+
s.files = `git ls-files`.split
|
34
|
+
|
35
|
+
s.required_ruby_version = '>= 2.1.0'
|
36
|
+
s.metadata = { 'lita_plugin_type' => 'handler' }
|
37
|
+
|
38
|
+
s.add_development_dependency 'bundler', '~> 1.5'
|
39
|
+
s.add_development_dependency 'rake', '~> 10.2'
|
40
|
+
s.add_development_dependency 'rubocop', '~> 0.25.0'
|
41
|
+
s.add_development_dependency 'rspec', '~> 3.0'
|
42
|
+
s.add_development_dependency 'fuubar', '~> 2.0'
|
43
|
+
s.add_development_dependency 'coveralls', '~> 0.7'
|
44
|
+
s.add_development_dependency 'simplecov', '~> 0.9'
|
45
|
+
|
46
|
+
s.add_runtime_dependency 'lita', '~> 3.3'
|
47
|
+
s.add_runtime_dependency 'octokit', '~> 3.3'
|
48
|
+
s.add_runtime_dependency 'lita-confirmation'
|
49
|
+
end
|
data/locales/en.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
en:
|
2
|
+
lita:
|
3
|
+
handlers:
|
4
|
+
github:
|
5
|
+
status:
|
6
|
+
good: "GitHub is reporting that all systems are green!"
|
7
|
+
minor: "GitHub is reporting minor issues (status:yellow)! Last message:\n%{created_on} :: %{body}"
|
8
|
+
major: "GitHub is reporting major issues (status:red)! Last message:\n%{created_on} :: %{body}"
|
9
|
+
github_repo:
|
10
|
+
method_disabled: "Sorry, this function has been disabled in the config"
|
11
|
+
repo_create:
|
12
|
+
pass: "Created %{org}/%{repo}: %{repo_url}"
|
13
|
+
fail: "Unable to create %{org}/%{repo}"
|
14
|
+
exists: "Unable to create %{org}/%{repo} as it already exists"
|
15
|
+
repo_delete:
|
16
|
+
pass: "Deleted %{org}/%{repo}"
|
17
|
+
fail: "Unable to delete %{org}/%{repo}"
|
18
|
+
repo_info:
|
19
|
+
reply: "%{repo} (private:%{private}) :: %{url}\nDesc: %{description}\nIssues: %{issues_count} PRs: %{pr_count}"
|
20
|
+
github_pr:
|
21
|
+
repo_merge:
|
22
|
+
pass: "Merged pull request #%{pr} from %{org}/%{branch}\n%{title}"
|
23
|
+
fail: "Failed trying to merge PR #%{pr} (%{title}) :: %{url}"
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright 2014 PagerDuty, Inc.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require 'rspec'
|
18
|
+
require 'lita/rspec'
|
19
|
+
# require 'coveralls'
|
20
|
+
# require 'simplecov'
|
21
|
+
|
22
|
+
# SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
23
|
+
# SimpleCov.start do
|
24
|
+
# add_filter 'spec/'
|
25
|
+
# end
|
26
|
+
|
27
|
+
require 'lita-github'
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright 2014 PagerDuty, Inc.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require 'spec_helper'
|
18
|
+
|
19
|
+
describe LitaGithub::Config do
|
20
|
+
before do
|
21
|
+
allow(Lita.config.handlers).to receive(:github).and_return(:ohai_cfg)
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '.config' do
|
25
|
+
it 'should get the Github handler config' do
|
26
|
+
extend LitaGithub::Config
|
27
|
+
expect(config).to eql :ohai_cfg
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright 2014 PagerDuty, Inc.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require 'spec_helper'
|
18
|
+
|
19
|
+
# Dummy class for testing some mixin
|
20
|
+
class DummyClass
|
21
|
+
include LitaGithub::Octo
|
22
|
+
end
|
23
|
+
|
24
|
+
describe LitaGithub::Octo do
|
25
|
+
before do
|
26
|
+
allow(Octokit::Client).to receive(:new).with(access_token: 'abc123').and_return(:ohai)
|
27
|
+
@conf_obj = double('Lita::Config', access_token: 'abc123')
|
28
|
+
allow(self).to receive(:config).and_return(@conf_obj)
|
29
|
+
allow_any_instance_of(DummyClass).to receive(:config).and_return(@conf_obj)
|
30
|
+
@dummy = DummyClass.new
|
31
|
+
@dummy.setup_octo(nil)
|
32
|
+
end
|
33
|
+
|
34
|
+
include LitaGithub::Octo
|
35
|
+
|
36
|
+
describe '.access_token' do
|
37
|
+
it 'should return the access token' do
|
38
|
+
expect(access_token).to eql 'abc123'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '.setup_octo' do
|
43
|
+
it 'should set up the Octokit client instance' do
|
44
|
+
expect(DummyClass.class_variable_get(:@@octo)).to eql :ohai
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '.octo' do
|
49
|
+
it 'should return the @@octo instance variable' do
|
50
|
+
expect(@dummy.octo).to eql :ohai
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright 2014 PagerDuty, Inc.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require 'spec_helper'
|
18
|
+
|
19
|
+
describe LitaGithub::R do
|
20
|
+
describe '::A_REG' do
|
21
|
+
subject { Regexp.new(LitaGithub::R::A_REG) }
|
22
|
+
|
23
|
+
context 'it should match' do
|
24
|
+
it 'gh ' do
|
25
|
+
expect(subject.match('gh ')).to_not be_nil
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'github ' do
|
29
|
+
expect(subject.match('github ')).to_not be_nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'it should not match' do
|
34
|
+
it 'gh' do
|
35
|
+
expect(subject.match('gh')).to be_nil
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'github' do
|
39
|
+
expect(subject.match('github')).to be_nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '::OPT_REGEX' do
|
45
|
+
subject { LitaGithub::R::OPT_REGEX }
|
46
|
+
|
47
|
+
context 'it should match' do
|
48
|
+
it 'test:pass' do
|
49
|
+
expect(subject.match(' test:pass')).to_not be_nil
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'test7_pass:pAss_test' do
|
53
|
+
expect(subject.match(' test7_pass:pAss_test')).to_not be_nil
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'it should not match' do
|
58
|
+
it 'test-stuff:fail' do
|
59
|
+
expect(subject.match(' test-stuff:fail')).to be_nil
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'test: fail' do
|
63
|
+
expect(subject.match(' test: fail')).to be_nil
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'test:fail' do
|
67
|
+
expect(subject.match('test:fail')).to be_nil
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '::REPO_REGEX' do
|
73
|
+
subject { Regexp.new(LitaGithub::R::REPO_REGEX) }
|
74
|
+
|
75
|
+
context 'it should match' do
|
76
|
+
it 'PagerDuty/lita-github' do
|
77
|
+
expect(subject.match('PagerDuty/lita-github')).to_not be_nil
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'lita-github' do
|
81
|
+
expect(subject.match('lita-github')).to_not be_nil
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'PagerDuty /lita-github' do
|
85
|
+
expect(subject.match('PagerDuty /lita-github')).to_not be_nil
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'PagerDuty/ lita-github' do
|
89
|
+
expect(subject.match('PagerDuty/ lita-github')).to_not be_nil
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright 2014 PagerDuty, Inc.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
describe LitaGithub do
|
18
|
+
describe '::VERSION' do
|
19
|
+
subject { LitaGithub::VERSION }
|
20
|
+
it { should be_an_instance_of String }
|
21
|
+
it { should match(/\d+\.\d+\.\d+(?:\-[a-zA-Z0-9_\.\-])?/) }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '::MAJ' do
|
25
|
+
subject { LitaGithub::MAJ }
|
26
|
+
it { should be_an_instance_of Fixnum }
|
27
|
+
it { should be >= 0 }
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '::MIN' do
|
31
|
+
subject { LitaGithub::MIN }
|
32
|
+
it { should be_an_instance_of Fixnum }
|
33
|
+
it { should be >= 0 }
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '::REV' do
|
37
|
+
subject { LitaGithub::REV }
|
38
|
+
it { should be_an_instance_of Fixnum }
|
39
|
+
it { should be >= 0 }
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright 2014 PagerDuty, Inc.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require 'spec_helper'
|
18
|
+
|
19
|
+
describe Lita::Handlers::Github, lita_handler: true do
|
20
|
+
let(:github) { Lita::Handlers::Forecast.new('robot') }
|
21
|
+
|
22
|
+
it { routes_command('gh status').to(:gh_status) }
|
23
|
+
it { routes_command('github status').to(:gh_status) }
|
24
|
+
it { routes_command('gh version').to(:gh_version) }
|
25
|
+
|
26
|
+
describe '#default_config' do
|
27
|
+
it 'should disable repo_delete by default' do
|
28
|
+
expect(Lita.config.handlers.github.repo_delete_enabled).to be_falsey
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should set repos to private by default' do
|
32
|
+
expect(Lita.config.handlers.github.repo_private_default).to be_truthy
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '.gh_status' do
|
37
|
+
context 'when GitHub status is good' do
|
38
|
+
before do
|
39
|
+
@octo = double(
|
40
|
+
'Octokit::Client',
|
41
|
+
github_status_last_message: {
|
42
|
+
status: 'good', body: 'Everything is operating normally.',
|
43
|
+
created_on: '1970-01-01 00:00:00 UTC'
|
44
|
+
}
|
45
|
+
)
|
46
|
+
allow_any_instance_of(Lita::Handlers::Github).to receive(:octo).and_return(@octo)
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should return the current GitHub status' do
|
50
|
+
send_command('gh status')
|
51
|
+
expect(replies.last).to eql('GitHub is reporting that all systems are green!')
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'when GitHub status is minor' do
|
56
|
+
before do
|
57
|
+
@octo = double(
|
58
|
+
'Octokit::Client',
|
59
|
+
github_status_last_message: {
|
60
|
+
status: 'minor', body: 'Minor issue',
|
61
|
+
created_on: '1970-01-01 00:00:21 UTC'
|
62
|
+
}
|
63
|
+
)
|
64
|
+
allow_any_instance_of(Lita::Handlers::Github).to receive(:octo).and_return(@octo)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should return the current GitHub status' do
|
68
|
+
send_command('gh status')
|
69
|
+
expect(replies.last).to eql(
|
70
|
+
"GitHub is reporting minor issues (status:yellow)! Last message:\n" \
|
71
|
+
'1970-01-01 00:00:21 UTC :: Minor issue'
|
72
|
+
)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context 'when GitHub status is major' do
|
77
|
+
before do
|
78
|
+
@octo = double(
|
79
|
+
'Octokit::Client',
|
80
|
+
github_status_last_message: {
|
81
|
+
status: 'major', body: 'Major issue',
|
82
|
+
created_on: '1970-01-01 00:00:42 UTC'
|
83
|
+
}
|
84
|
+
)
|
85
|
+
allow_any_instance_of(Lita::Handlers::Github).to receive(:octo).and_return(@octo)
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'should return the current GitHub status' do
|
89
|
+
send_command('gh status')
|
90
|
+
expect(replies.last).to eql(
|
91
|
+
"GitHub is reporting major issues (status:red)! Last message:\n" \
|
92
|
+
'1970-01-01 00:00:42 UTC :: Major issue'
|
93
|
+
)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe '.gh_version' do
|
99
|
+
it 'should send back the Lita version' do
|
100
|
+
send_command('gh version')
|
101
|
+
expect(replies.last).to eql "lita-github v#{LitaGithub::VERSION}"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
metadata
ADDED
@@ -0,0 +1,214 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lita-github
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tim Heckman
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.2'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rubocop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.25.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.25.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: fuubar
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: coveralls
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.7'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.7'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.9'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.9'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: lita
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '3.3'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '3.3'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: octokit
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '3.3'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '3.3'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: lita-confirmation
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
description: Lita handler for managing your GitHub account/organization; handler not
|
154
|
+
ready for production
|
155
|
+
email: tim@pagerduty.com
|
156
|
+
executables: []
|
157
|
+
extensions: []
|
158
|
+
extra_rdoc_files: []
|
159
|
+
files:
|
160
|
+
- ".gitignore"
|
161
|
+
- ".rspec"
|
162
|
+
- ".rubocop.yml"
|
163
|
+
- ".travis.yml"
|
164
|
+
- Gemfile
|
165
|
+
- Gemfile.lock
|
166
|
+
- LICENSE
|
167
|
+
- README.md
|
168
|
+
- Rakefile
|
169
|
+
- lib/lita-github.rb
|
170
|
+
- lib/lita-github/config.rb
|
171
|
+
- lib/lita-github/octo.rb
|
172
|
+
- lib/lita-github/r.rb
|
173
|
+
- lib/lita-github/version.rb
|
174
|
+
- lib/lita/handlers/github.rb
|
175
|
+
- lita-github.gemspec
|
176
|
+
- locales/en.yml
|
177
|
+
- spec/spec_helper.rb
|
178
|
+
- spec/unit/lita-github/config_spec.rb
|
179
|
+
- spec/unit/lita-github/octo_spec.rb
|
180
|
+
- spec/unit/lita-github/r_spec.rb
|
181
|
+
- spec/unit/lita-github/version_spec.rb
|
182
|
+
- spec/unit/lita/handlers/github_spec.rb
|
183
|
+
homepage: https://github.com/PagerDuty/lita-github
|
184
|
+
licenses:
|
185
|
+
- Apache 2.0
|
186
|
+
metadata:
|
187
|
+
lita_plugin_type: handler
|
188
|
+
post_install_message:
|
189
|
+
rdoc_options: []
|
190
|
+
require_paths:
|
191
|
+
- lib
|
192
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
193
|
+
requirements:
|
194
|
+
- - ">="
|
195
|
+
- !ruby/object:Gem::Version
|
196
|
+
version: 2.1.0
|
197
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
requirements: []
|
203
|
+
rubyforge_project:
|
204
|
+
rubygems_version: 2.2.2
|
205
|
+
signing_key:
|
206
|
+
specification_version: 4
|
207
|
+
summary: GitHub repo/org management in Lita; handler not ready for production
|
208
|
+
test_files:
|
209
|
+
- spec/spec_helper.rb
|
210
|
+
- spec/unit/lita-github/config_spec.rb
|
211
|
+
- spec/unit/lita-github/octo_spec.rb
|
212
|
+
- spec/unit/lita-github/r_spec.rb
|
213
|
+
- spec/unit/lita-github/version_spec.rb
|
214
|
+
- spec/unit/lita/handlers/github_spec.rb
|