Comment 2 for bug 1115283

Revision history for this message
Ryan Faulkner (bobs-ur-uncle) wrote :

Ah I see. You're correct in assuming that I'm looking to create a tag. However, the above steps seem to be omitting some calls to actually create the tag in .git/refs/tags or .git/packed-refs nor is it visible when I run 'git tag'. (http://git-scm.com/book/en/Git-Basics-Tagging)

If I try to to add the object to a repo object store I see the following:

>>> from dulwich.repo import Repo
>>> from dulwich.objects import Tag
>>> r = Repo(".")
>>> object_store = r.object_store
>>> tag = Tag()
>>> tag.tagger = 'rfaulk'
>>> tag.message = 'test tag 1,2.'
>>> tag.name = 'test-tag'
>>> object_store.add_object(tag)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/dulwich/object_store.py", line 610, in add_object
    dir = os.path.join(self.path, obj.id[:2])
  File "/Library/Python/2.7/site-packages/dulwich/objects.py", line 492, in id
    return self.sha().hexdigest()
  File "/Library/Python/2.7/site-packages/dulwich/objects.py", line 483, in sha
    new_sha.update(self._header())
  File "/Library/Python/2.7/site-packages/dulwich/objects.py", line 462, in _header
    return object_header(self.type, self.raw_length())
  File "/Library/Python/2.7/site-packages/dulwich/objects.py", line 467, in raw_length
    for chunk in self.as_raw_chunks():
  File "/Library/Python/2.7/site-packages/dulwich/objects.py", line 253, in as_raw_chunks
    self._chunked_text = self._serialize()
  File "/Library/Python/2.7/site-packages/dulwich/objects.py", line 654, in _serialize
    chunks.append("%s %s\n" % (_OBJECT_HEADER, self._object_sha))
AttributeError: _object_sha

Am I missing something here?