Module: LitaGithub::Repo

Included in:
Lita::Handlers::GithubIssues, Lita::Handlers::GithubPR, Lita::Handlers::GithubRepo
Defined in:
lib/lita-github/repo.rb

Overview

Github handler common-use Repository methods

Constant Summary collapse

PR_LIST_MAX_COUNT =

Maximum number of allowed PRs to be returned when listing

Author:

20

Instance Method Summary collapse

Instance Method Details

#repo?(r) ⇒ Boolean

Determine if r is a Github repository

Parameters:

  • r (String)

    canonical name of the repository

Returns:

  • (Boolean)

Author:



39
40
41
# File 'lib/lita-github/repo.rb', line 39

def repo?(r)
  octo.repository?(r)
end

#repo_has_team?(full_name, team_id) ⇒ TrueClass, FalseClass

Determine if the team is already on the repository

Parameters:

  • full_name (String)

    the canonical name of the repository

  • team_id (Integer)

    the id for the Github team

Returns:

  • (TrueClass)

    if the team is already on the repo

  • (FalseClass)

    if the team is not on the repo



58
59
60
61
# File 'lib/lita-github/repo.rb', line 58

def repo_has_team?(full_name, team_id)
  octo.repository_teams(full_name).each { |t| return true if t[:id] == team_id }
  false
end

#repo_match(md) ⇒ Array

Helper method for pulling widely used matches out of a MatchData object

Parameters:

  • md (MatchData)

    the match data used to get the matches

Returns:

  • (Array)
    0

    is the org name, [1] is the repo name

Author:



48
49
50
# File 'lib/lita-github/repo.rb', line 48

def repo_match(md)
  [organization(md['org']), md['repo']]
end

#rpo(org, repo) ⇒ String

Combine org and repo to get the canonical name

Parameters:

  • org (String)

    organization name

  • repo (String)

    repository name without org prefixed

Returns:

  • (String)

    canonical name of repo: <Org>/<Repo>

Author:



31
32
33
# File 'lib/lita-github/repo.rb', line 31

def rpo(org, repo)
  "#{org}/#{repo}"
end