Method: Metior::GitHub::Repository#load_commits
- Defined in:
- lib/metior/github/repository.rb
permalink #load_commits(range) ⇒ Hashie::Mash, ... (private)
Note:
GitHub API is currently limited to 60 calls a minute, so you won't be able to query branches with more than 2100 commits (35 commits per call).
This method uses Octokit to load all commits from the given commit range
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/metior/github/repository.rb', line 78 def load_commits(range) base_commit = nil commits = [] page = 1 begin loop do new_commits = Octokit.commits(@path, range.last, :page => page) base_commit_index = new_commits.find_index do |commit| commit.id == range.first end unless base_commit_index.nil? commits += new_commits[0..base_commit_index-1] base_commit = new_commits[base_commit_index] break end commits += new_commits page += 1 end rescue Octokit::NotFound end [base_commit, commits] end |