diff --git a/app/jobs/commit_job.rb b/app/jobs/commit_job.rb index b48dae88..ed44425a 100644 --- a/app/jobs/commit_job.rb +++ b/app/jobs/commit_job.rb @@ -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. diff --git a/app/models/repository.rb b/app/models/repository.rb index 64901b56..7949753e 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -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 diff --git a/app/models/scoring_engine.rb b/app/models/scoring_engine.rb index 5ea8abed..3ae0856d 100644 --- a/app/models/scoring_engine.rb +++ b/app/models/scoring_engine.rb @@ -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)