lib/git/pr/github.rb in git-pr-0.0.2 vs lib/git/pr/github.rb in git-pr-0.0.3
- old
+ new
@@ -9,16 +9,18 @@
@git = git_properties
Octokit.configure do |c|
c.login = @git.login
c.password = @git.api_token
+ c.api_endpoint = @git.api_endpoint unless @git.api_endpoint.empty?
end
end
def list_pull_requests(profile, mine)
if profile
- repositories = @git.repository_profile(profile)
+ repositories = profile == :all ? all_repositories
+ : @git.repository_profile(profile)
else
repositories = [@git.repository]
end
[].tap do |prs|
@@ -41,9 +43,21 @@
message)
response.state == 'open' ? response : raise(Failed, response.state)
rescue Octokit::UnprocessableEntity => e
message = e.message.match(/message: (.*)/)[1].sub(/ \/\/.*/, '')
raise Failed, message
+ end
+
+ private
+ def all_repositories
+ repositories = []
+
+ Octokit.organizations.map(&:login).each do |org|
+ repositories << Octokit.organization_repositories(org).map(&:full_name)
+ end
+ repositories << Octokit.repositories.map(&:full_name)
+
+ repositories
end
end
end
end