lita-github 0.0.11 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f9d776a2cd23860fda771d4efd3a3602b672cfb0
4
- data.tar.gz: 074232e708387b5457e8162b247ab40042fee1cb
3
+ metadata.gz: 4bfd623a40a5a5b1c9fbc462dc72f0b286a43dfd
4
+ data.tar.gz: 84b1958cb141a7295fb744de2ee3d3e6dd2dc798
5
5
  SHA512:
6
- metadata.gz: 656ec110d8e8461509241198219d5fa7cd7fca49cf92ce6f50bd0260ebfddc3e74a47cc09cfca4c4f948bbfa04d10f0ee614223f16c552a0d7cf86127cc5c80c
7
- data.tar.gz: a8cb3ffc5acc22b40f504027d303978eff9043c00ae8bcce84dbc51d73e69adf08610c174edf316b0cea875917b54bf8bed5d2a8db44180d17ea4b029cea6ce5
6
+ metadata.gz: a82a4d278f7c38781903bd5d9547ed5e784532e96d3243cbc0c066c48f71ed2360044f275b3dd3e4725ae3a68f651ffa1161a9658ba1bbe560fc05b8215fefb6
7
+ data.tar.gz: 1f454fe23289fa3c0763fa4e889bb09767c80ee6b9203bbdad83810de3fd5fe279b7ce8885df1e3548bfe4a1861606bf1edd9f62a58f0162ee88e4ce2fbec11e
data/.gitignore CHANGED
@@ -26,10 +26,9 @@ build/
26
26
 
27
27
  # for a library or gem, you might want to ignore these files since the code is
28
28
  # intended to run in multiple environments; otherwise, check them in:
29
- # Gemfile.lock
30
- # .ruby-version
31
- # .ruby-gemset
32
29
  Gemfile.lock
30
+ .ruby-version
31
+ .ruby-gemset
33
32
 
34
33
  # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
34
  .rvmrc
@@ -16,7 +16,12 @@
16
16
 
17
17
  module LitaGithub
18
18
  # Github handler Lita configuration methods
19
+ #
20
+ # @author Tim Heckman <tim@pagerduty.com>
19
21
  module Config
22
+ # Return the Lita::Config object for the Github handler
23
+ #
24
+ # @return [Lita::Config] the config object for Lita::Handlers::Github
20
25
  def config
21
26
  Lita.config.handlers.github
22
27
  end
@@ -16,7 +16,14 @@
16
16
 
17
17
  module LitaGithub
18
18
  # Github handler common-use method filters
19
+ #
20
+ # @author Tim Heckman <tim@pagerduty.com>
19
21
  module Filters
22
+ # Returns whether or not the function has been disabled in the config
23
+ #
24
+ # @param method [String] the method name, usually just __method__
25
+ # @return [TrueClass] if function is disabled
26
+ # @return [FalseClass] if function is disabled
20
27
  def func_disabled?(method)
21
28
  config.send("#{method}_enabled".to_sym) ? false : true
22
29
  end
@@ -18,19 +18,33 @@ require 'octokit'
18
18
 
19
19
  module LitaGithub
20
20
  # Github handler common-use Octokit methods
21
+ #
22
+ # @author Tim Heckman <tim@pagerduty.com>
21
23
  module Octo
22
- # pull the access token from the config
24
+ # Accessor method for the Github access token in the config
25
+ #
26
+ # @author Tim Heckman <tim@pagerduty.com>
27
+ # @return [String] the Github API access token
23
28
  def access_token
24
29
  config.access_token
25
30
  end
26
31
 
27
- # set up the Octokit client
32
+ # To be used to set up Octokit::Client when loading the Handler class
33
+ #
34
+ # @author Tim Heckman <tim@pagerduty.com>
35
+ # @return [NilClass]
28
36
  def setup_octo(_)
29
37
  @@octo ||= Octokit::Client.new(access_token: access_token)
30
38
  @@octo.auto_paginate = true
39
+ nil
31
40
  end
32
41
 
33
- # object access method for Octokit client
42
+ # Object access method for Octokit client
43
+ #
44
+ # @author Tim Heckman <tim@pagerduty.com>
45
+ # @return [Octokit::Client]
46
+ # @example
47
+ # octo.create_team('PagerDuty', name: 'Example Group', perms:pull)
34
48
  def octo
35
49
  @@octo
36
50
  end
@@ -16,6 +16,8 @@
16
16
 
17
17
  module LitaGithub
18
18
  # Github handler common-use regex constants
19
+ #
20
+ # @author Tim Heckman <tim@pagerduty.com>
19
21
  module R
20
22
  # command alias regex (!gh or !github for example)
21
23
  A_REG ||= '(?:gh|github)\s+?'
@@ -17,20 +17,44 @@
17
17
  module LitaGithub
18
18
  # Github handler common-use Repository methods
19
19
  module Repo
20
+ # Maximum number of allowed PRs to be returned when listing
21
+ #
22
+ # @author Tim Heckman <tim@pagerduty.com>
20
23
  PR_LIST_MAX_COUNT = 20
21
24
 
25
+ # Combine org and repo to get the canonical name
26
+ #
27
+ # @author Tim Heckman <tim@pagerduty.com>
28
+ # @param org [String] organization name
29
+ # @param repo [String] repository name without org prefixed
30
+ # @return [String] canonical name of repo: <Org>/<Repo>
22
31
  def rpo(org, repo)
23
32
  "#{org}/#{repo}"
24
33
  end
25
34
 
35
+ # Determine if r is a Github repository
36
+ #
37
+ # @author Tim Heckman <tim@pagerduty.com>
38
+ # @param r [String] canonical name of the repository
26
39
  def repo?(r)
27
40
  octo.repository?(r)
28
41
  end
29
42
 
43
+ # Helper method for pulling widely used matches out of a MatchData object
44
+ #
45
+ # @author Tim Heckman <tim@pagerduty.com>
46
+ # @param md [MatchData] the match data used to get the matches
47
+ # @return [Array] [0] is the org name, [1] is the repo name
30
48
  def repo_match(md)
31
49
  [organization(md['org']), md['repo']]
32
50
  end
33
51
 
52
+ # Determine if the team is already on the repository
53
+ #
54
+ # @param full_name [String] the canonical name of the repository
55
+ # @param team_id [Integer] the id for the Github team
56
+ # @return [TrueClass] if the team is already on the repo
57
+ # @return [FalseClass] if the team is not on the repo
34
58
  def repo_has_team?(full_name, team_id)
35
59
  octo.repository_teams(full_name).each { |t| return true if t[:id] == team_id }
36
60
  false
@@ -15,7 +15,14 @@
15
15
  # limitations under the License.
16
16
 
17
17
  # Administer your Hub of Gits with Lita!
18
+ #
19
+ # The namespace for non-handler code of the lita-github plugin
20
+ #
21
+ # @author Tim Heckman <tim@pagerduty.com>
18
22
  module LitaGithub
19
- VERSION = '0.0.11'
23
+ # lita-github version
24
+ VERSION = '0.0.12'
25
+
26
+ # lita-github version split amongst different revisions
20
27
  MAJ, MIN, REV = VERSION.split('.').map(&:to_i)
21
28
  end
@@ -88,7 +88,7 @@ module Lita
88
88
 
89
89
  def status(response)
90
90
  status = octo.github_status_last_message
91
- response.reply(t("status.#{status[:status]}", status))
91
+ response.reply(t("status.#{status[:status]}", status.to_h))
92
92
  end
93
93
 
94
94
  def version(response)
@@ -763,6 +763,15 @@ Name: Interns, Slug: interns, ID: 84, Perms: pull
763
763
  end
764
764
  end
765
765
 
766
+ context 'when it finds a repo with no teams but the owners' do
767
+ before { allow(@octo_obj).to receive(:repository_teams).and_return([]) }
768
+
769
+ it 'should return the fact there are no teams' do
770
+ send_command("gh repo teams #{github_org}/lita-test")
771
+ expect(replies.last).to eql "Beyond the 'GrapeDuty' org owners, GrapeDuty/lita-test has no teams"
772
+ end
773
+ end
774
+
766
775
  context 'when the repo is not valid' do
767
776
  before { allow(@octo_obj).to receive(:repository_teams).and_raise(Octokit::NotFound.new) }
768
777
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-github
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Heckman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-14 00:00:00.000000000 Z
11
+ date: 2014-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler