getsentry / raven-python

Raven is the legacy Python client for Sentry (getsentry.com) — replaced by sentry-python
https://sentry.io
BSD 3-Clause "New" or "Revised" License
1.68k stars 657 forks source link

raven.fetch_git_sha doesn't support detached head checkouts #676

Open brentc opened 8 years ago

brentc commented 8 years ago

When a checkout is in 'detached' head mode, .git/HEAD contains a git commit reference. fetch_git_sha doesn't handle this case.

We'd like to use this feature for our codebase, but our deploy process currently uses this type of checkout.

$ git checkout --force ea0bfa7b83b5a6b816a1da0360bde4950a73fa28
Note: checking out 'ea0bfa7b83b5a6b816a1da0360bde4950a73fa28'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD is now at ea0bfa7... [omitted]
$ cat .git/HEAD 
ea0bfa7b83b5a6b816a1da0360bde4950a73fa28
$ python -c 'import raven; raven.fetch_git_sha(".")'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/brent/virtualenvs/Kira-Talk/lib/python2.7/site-packages/raven/versioning.py", line 42, in fetch_git_sha
    raise InvalidGitRepository('Unable to find ref to head "%s" in repository' % (head,))
raven.exceptions.InvalidGitRepository: Unable to find ref to head "ea0bfa7b83b5a6b816a1da0360bde4950a73fa28" in repository
tvavrys commented 8 years ago

+1