lib/octopi/commit.rb in fcoury-octopi-0.0.9 vs lib/octopi/commit.rb in fcoury-octopi-0.0.11
- old
+ new
@@ -19,16 +19,17 @@
# find_all(repo, :branch => "develop") # repo must be an object
# find_all("octopi", :user => "fcoury") # user must be provided
# find_all(:user => "fcoury", :repo => "octopi") # branch defaults to master
#
def self.find_all(*args)
+ api = args.last.is_a?(Api) ? args.pop : ANONYMOUS_API
repo = args.first
user ||= repo.owner if repo.is_a? Repository
user, repo_name, opts = extract_user_repository(*args)
self.validate_args(user => :user, repo_name => :repo)
branch = opts[:branch] || "master"
-
- commits = super user, repo_name, branch
+ api = ANONYMOUS_API if repo.is_a?(Repository) && !repo.private
+ commits = super user, repo_name, branch, api
commits.each { |c| c.repository = repo } if repo.is_a? Repository
commits
end
# TODO: Make find use hashes like find_all