Skip to content

Commit

Permalink
refs joshsoftware#189 removed the tap method on fetch_repo, fixed typ…
Browse files Browse the repository at this point in the history
…o in repository model and additional exception handling on commit fetch job
  • Loading branch information
sethu committed Nov 8, 2016
1 parent 25dc59a commit 2ab7cde
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions app/jobs/commit_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ def fetch_commits(repo, user, round, duration)
rescue Github::Error::NotFound
# repository moved or deleted means we no longer care about this repos.
repo.destroy
rescue Github::Error::UnavailableForLegalReasons
# repository permission invoked.
repo.destroy
rescue Github::Error::Unauthorized
# Auth token issue or Access has been denied OR Rate limit hit.

Expand Down
2 changes: 1 addition & 1 deletion app/models/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def score_commits(round = nil)
engine = ScoringEngine.new(self)

_commits = self.commits.where(auto_score: nil)
_commite = _commits.where(round: round) if round
_commits = _commits.where(round: round) if round

_commits.each do |commit|
if commit.message =~ PULL_REQ_MERGE_REGX
Expand Down
10 changes: 5 additions & 5 deletions app/models/scoring_engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ def fetch_repo
# Default git pull will pull 'origin/master'. We need to handle the case
# that repository has no master!
# Rollbar#14
self.git = Git.open(repo_dir).tap do |g|
branch = g.branches.local.first.name # usually 'master'
remote = g.config["branch.#{branch}.remote"] # usually just 'origin'
g.pull(remote, branch)
end
self.git = Git.open(repo_dir)
branch = self.git.branches.local.first.name # usually 'master'
remote = self.git.config["branch.#{branch}.remote"] # usually just 'origin'
self.git.pull(remote, branch)
else
self.git = Git.clone(repo.ssh_url, repo.id, path: Rails.root.join(config[:repositories]).to_s)
end
self.git
end

def comments_score(commit)
Expand Down

0 comments on commit 2ab7cde

Please sign in to comment.