Skip to content

Commit

Permalink
looking across all branches for commits
Browse files Browse the repository at this point in the history
  • Loading branch information
seejee committed Jun 16, 2011
1 parent b76d314 commit fefc3f8
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions app/models/github/submission_commits_finder.rb
Expand Up @@ -21,9 +21,7 @@ def find_and_store_new_commits
def find_and_store_new_commits_for_submission(submission)

puts "Looking for new commits in: #{submission.github_repository}"
all_commits = @client.commits(submission.github_repository).map do |c|
GithubCommit.new(c)
end
all_commits = get_commits_across_branches(submission.github_repository)

user_commits = all_commits.select do |commit|
commit.login == submission.user.github_account_name &&
Expand All @@ -42,5 +40,21 @@ def find_and_store_new_commits_for_submission(submission)

end

def get_commits_across_branches(repository)
@client.branches(repository).keys.inject([]) do |results, branch|
results.concat(get_commits_for_branch(repository, branch))
end
end

def get_commits_for_branch(repository, branch)
begin
@client.commits(repository, branch).map {|c| GithubCommit.new(c)}
rescue
#If this repo is a fork, branches will be returned by the Github API
#that don't exist on this fork.
[]
end
end

end
end

0 comments on commit fefc3f8

Please sign in to comment.