SquareSquash / web

Squash’s front-end and API host.
http://www.squash.io
Apache License 2.0
962 stars 135 forks source link

Git fetch fails with 'not a git repository' #99

Closed benjamin-bader closed 10 years ago

benjamin-bader commented 10 years ago

I noticed that posting to api/1.0/notify never resulted in any Occurrences being created. After tailing the production log, it seems that either Squash or ruby-git is confused:

E, [2014-01-06T23:37:29.061445 #29438] ERROR -- : -- ERROR IN OccurrencesWorker 47798820 --
E, [2014-01-06T23:37:29.061694 #29438] ERROR -- : git fetch "origin"  2>&1:fatal: Not a git repository: '/home/squash/web/tmp/repos/af27dac12eff9b6caf58bd0a0aff05d90524b25e.git'

E, [2014-01-06T23:37:29.061820 #29438] ERROR -- : /home/squash/.rvm/gems/ruby-1.9.3-p484@squash/bundler/gems/ruby-git-4aae92a0dee4/lib/git/lib.rb:742:in `command'
/home/squash/.rvm/gems/ruby-1.9.3-p484@squash/bundler/gems/ruby-git-4aae92a0dee4/lib/git/lib.rb:594:in `fetch'
/home/squash/.rvm/gems/ruby-1.9.3-p484@squash/bundler/gems/ruby-git-4aae92a0dee4/lib/git/base.rb:345:in `fetch'
/home/squash/web/app/models/project.rb:195:in `block in repo'
/home/squash/web/lib/file_mutex.rb:51:in `block (2 levels) in lock!'
/home/squash/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/timeout.rb:69:in `timeout'
/home/squash/web/lib/file_mutex.rb:49:in `block in lock!'
/home/squash/web/lib/file_mutex.rb:46:in `open'
/home/squash/web/lib/file_mutex.rb:46:in `lock!'
/home/squash/web/app/models/project.rb:195:in `repo'
/home/squash/web/lib/blamer/recency.rb:63:in `resolve_revision'
/home/squash/web/lib/workers/occurrences_worker.rb:179:in `set_deploy_and_commit'
/home/squash/web/lib/workers/occurrences_worker.rb:77:in `perform'
/home/squash/web/lib/workers/occurrences_worker.rb:45:in `perform'
/home/squash/web/lib/background_runner/multithread.rb:31:in `block in run'
/home/squash/web/lib/multithread.rb:64:in `spinoff'
/home/squash/web/lib/background_runner/multithread.rb:31:in `run'
/home/squash/web/lib/background_runner.rb:38:in `run'
/home/squash/web/app/controllers/api/v1_controller.rb:63:in `notify'
...

I've attempted to track down why this is failing, but without much success. I can manually git fetch "origin", using the Passenger user. In the rails console, Git.open("/path/to/tmp/repo").fetch("origin") succeeds by returning the empty string. As far as my middling git knowledge can tell, the repository is intact and accessible. Any idea what could be going wrong?

Using Ubuntu 12.04, nginx, and Passenger on MRI 1.9.3-p484, FWIW.

RISCfuture commented 10 years ago

Try blowing away /home/squash/web/tmp/repos/af27dac12eff9b6caf58bd0a0aff05d90524b25e.git, or at least, verifying that git --git-dir=/home/squash/web/tmp/repos/af27dac12eff9b6caf58bd0a0aff05d90524b25e.git fetch works or fails.

benjamin-bader commented 10 years ago

Interesting! I'd already deleted and re-created the repo, unfortunately to no effect. Passing --git-dir gives the same error message. Since --git-dir is supposed to be given the path to the .git directory, that makes sense.

git --git-dir=/home/squash/web/tmp/repos/af27dac12eff9b6caf58bd0a0aff05d90524b25e.git fetch fails, but git --git-dir=/home/squash/web/tmp/repos/af27dac12eff9b6caf58bd0a0aff05d90524b25e.git/.git fetch works.

Is this actually a Squash issue? It seems like this is the sort of problem that everyone would have if it were.

RISCfuture commented 10 years ago

How did you recreate the repo? Using Squash? Squash creates mirror repos, which are different than just running a normal git clone.

benjamin-bader commented 10 years ago

Using Squash, AFAIK. The clone process appeared to begin the first time I posted to notify. Incidentally, that timed out, but the repo is pretty big and the clone appeared to finish, so whatevs.

benjamin-bader commented 10 years ago

As an update, I tried installing squash again, this time on Ubuntu lucid. Using git 1.7.0.4 (the default from apt-get), everything works. My immediate problem is resolved, but maybe something in the docs should indicate known-good git versions?

RISCfuture commented 10 years ago

The read me does specify Git 1.7+ is required.

benjamin-bader commented 10 years ago

The readme does say that, yes - the version of git in Ubuntu 12.04, where this bug was observed, is git version 1.7.9.5. I was referring to an upper bound on git versions, not a lower bound :)