Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug reporting fails when git repo has not been fetched #129

Open
JasonBarnabe opened this issue Mar 13, 2017 · 0 comments
Open

Bug reporting fails when git repo has not been fetched #129

JasonBarnabe opened this issue Mar 13, 2017 · 0 comments

Comments

@JasonBarnabe
Copy link

project.repo.object(revision) throws when it can't find the commit (the commit happened after the last time the repo was fetched).

E, [2017-03-13T09:01:24.885656 #27338] ERROR -- : -- ERROR IN OccurrencesWorker 49810320 --
E, [2017-03-13T09:01:24.885739 #27338] ERROR -- : git cat-file "-t" "6e96b806e7ba214246c08bf2c32618af2b261df3"  2>&1:error: unable to find 6e96b806e7ba214246c08bf2c32618af2b261df3
fatal: git cat-file 6e96b806e7ba214246c08bf2c32618af2b261df3: bad file
E, [2017-03-13T09:01:24.886029 #27338] ERROR -- : /home/web/.rvm/gems/ruby-2.3.0@squash/bundler/gems/ruby-git-eeab421f5ca7/lib/git/lib.rb:724:in `command'
/home/web/.rvm/gems/ruby-2.3.0@squash/bundler/gems/ruby-git-eeab421f5ca7/lib/git/lib.rb:136:in `object_type'
/home/web/.rvm/gems/ruby-2.3.0@squash/bundler/gems/ruby-git-eeab421f5ca7/lib/git/object.rb:262:in `new'
/home/web/.rvm/gems/ruby-2.3.0@squash/bundler/gems/ruby-git-eeab421f5ca7/lib/git/base.rb:153:in `object'
/var/www/apps/squash_20170319/lib/blamer/recency.rb:61:in `resolve_revision'
/var/www/apps/squash_20170319/lib/workers/occurrences_worker.rb:189:in `set_deploy_and_commit'
/var/www/apps/squash_20170319/lib/workers/occurrences_worker.rb:77:in `perform'
/var/www/apps/squash_20170319/lib/workers/occurrences_worker.rb:45:in `perform'
/var/www/apps/squash_20170319/lib/background_runner/multithread.rb:31:in `block in run'
/var/www/apps/squash_20170319/lib/multithread.rb:64:in `spinoff'
/var/www/apps/squash_20170319/lib/background_runner/multithread.rb:31:in `run'
/var/www/apps/squash_20170319/lib/background_runner.rb:38:in `run'
/var/www/apps/squash_20170319/app/controllers/api/v1_controller.rb:63:in `notify'

The code seems to expect it to return nil, when in fact it raises an exception. The fix:

diff --git a/lib/blamer/recency.rb b/lib/blamer/recency.rb
index 23a211f..d5ef0e4 100644
--- a/lib/blamer/recency.rb
+++ b/lib/blamer/recency.rb
@@ -58,7 +58,12 @@ module Blamer
   class Recency < Base
 
     def self.resolve_revision(project, revision)
-      commit   = project.repo.object(revision)
+      begin
+        commit   = project.repo.object(revision)
+      rescue Git::GitExecuteError
+        # Try fetching
+        commit = nil
+      end
       if commit.nil?
         project.repo(&:fetch)
         commit = project.repo.object(revision)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant