On Wed, 2013-02-06 at 11:40 +0000, Ryan Faulkner 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)
These steps create an annotated 'tag' object. To create a tag, add the
relevant ref to your git repository. E.g.
r['refs/tags/foo'] = o.id
where o is either an annotated tag object or another object the tag
refers to.
> 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?
You need to set an object in the tag as well.
On Wed, 2013-02-06 at 11:40 +0000, Ryan Faulkner wrote: git-scm. com/book/ en/Git- Basics- Tagging)
> 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://
These steps create an annotated 'tag' object. To create a tag, add the
relevant ref to your git repository. E.g.
r['refs/tags/foo'] = o.id
where o is either an annotated tag object or another object the tag
refers to.
> If I try to to add the object to a repo object store I see the store.add_ object( tag) Python/ 2.7/site- packages/ dulwich/ object_ store.py" , line 610, in add_object join(self. path, obj.id[:2]) Python/ 2.7/site- packages/ dulwich/ objects. py", line 492, in id ).hexdigest( ) Python/ 2.7/site- packages/ dulwich/ objects. py", line 483, in sha update( self._header( )) Python/ 2.7/site- packages/ dulwich/ objects. py", line 462, in _header header( self.type, self.raw_length()) Python/ 2.7/site- packages/ dulwich/ objects. py", line 467, in raw_length raw_chunks( ): Python/ 2.7/site- packages/ dulwich/ objects. py", line 253, in as_raw_chunks Python/ 2.7/site- packages/ dulwich/ objects. py", line 654, in _serialize
> 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_
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "/Library/
> dir = os.path.
> File "/Library/
> return self.sha(
> File "/Library/
> new_sha.
> File "/Library/
> return object_
> File "/Library/
> for chunk in self.as_
> File "/Library/
> self._chunked_text = self._serialize()
> File "/Library/
> chunks.append("%s %s\n" % (_OBJECT_HEADER, self._object_sha))
> AttributeError: _object_sha
>
> Am I missing something here?
You need to set an object in the tag as well.
tag.object = (type, somesha)
Cheers,
Jelmer