Comment 4 for bug 1115283

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

Thanks Jelmer, the feedback was very helpful.

I ended up creating tags by doing the following:

        # Open the repo
        _repo = Repo(self.config['top_dir'])
        master_branch = 'master'

        # Build the commit object
        blob = Blob.from_string("empty")
        tree = Tree()
        tree.add(tag, 0100644, blob.id)

        commit = Commit()
        commit.tree = tree.id
        commit.author = commit.committer = author
        commit.commit_time = commit.author_time = int(time())
        tz = parse_timezone('-0200')[0]
        commit.commit_timezone = commit.author_timezone = tz
        commit.encoding = "UTF-8"
        commit.message = 'Tagging repo for deploy: ' + message

        # Add objects to the repo store instance
        object_store = _repo.object_store
        object_store.add_object(blob)
        object_store.add_object(tree)
        object_store.add_object(commit)
        _repo.refs['refs/heads/' + master_branch] = commit.id

        # Build the tag object and tag
        tag = Tag()
        tag.tagger = author
        tag.message = message
        tag.name = tag
        tag.object = (Commit, commit.id)
        tag.tag_time = commit.author_time
        tag.tag_timezone = tz
        object_store.add_object(tag)
        _repo['refs/tags/' + tag] = tag.id

This doesn't seem to be included in the documentation. I'm wondering, would it be helpful to you if I added this to the tutorial docs then sent a pull request to jelmer/dulwich?