lib/lita/handlers/github_repo.rb in lita-github-0.0.3 vs lib/lita/handlers/github_repo.rb in lita-github-0.0.4

- old
+ new

@@ -87,13 +87,14 @@ response.reply(delete_repo(org, repo)) end def repo_info(response) org, repo = repo_match(response) + full_name = rpo(org, repo) opts = {} - r_obj = octo.repository(rpo(org, repo)) - p_obj = octo.pull_requests(rpo(org, repo)) + r_obj = octo.repository(full_name) + p_obj = octo.pull_requests(full_name) opts[:repo] = r_obj[:full_name] opts[:description] = r_obj[:description] opts[:private] = r_obj[:private] opts[:url] = r_obj[:html_url] @@ -114,10 +115,11 @@ o[k] = v unless o.key?(k) end o end + # TODO: convert this to a mixin method for reuse def repo_match(response) md = response.match_data [organization(md['org']), md['repo']] end @@ -157,29 +159,31 @@ config.repo_private_default end end def create_repo(org, repo, opts) + full_name = rpo(org, repo) reply = nil begin octo.create_repository(repo, opts) ensure - if repo?(rpo(org, repo)) - repo_url = "https://github.com/#{rpo(org, repo)}" + if repo?(full_name) + repo_url = "https://github.com/#{full_name}" reply = t('repo_create.pass', org: org, repo: repo, repo_url: repo_url) else reply = t('repo_create.fail', org: org, repo: repo) end end reply end def delete_repo(org, repo) + full_name = rpo(org, repo) reply = nil begin - octo.delete_repository(rpo(org, repo)) + octo.delete_repository(full_name) ensure - if repo?(rpo(org, repo)) + if repo?(full_name) reply = t('repo_delete.fail', org: org, repo: repo) else reply = t('repo_delete.pass', org: org, repo: repo) end end