libgit2 / libgit2/pygit2

Custom Python ODB backends - write() support

Open
#1,057 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.7k
Forks
408
Avg merge
2d 57m
Merged PRs (30d)
7

Description

Is there any support for implementing write() for custom python ODB backends?

I noticed it wasn't in the docs, but tried implementing it like so:

class MyOdbBackend(pygit2.OdbBackend):

    # snip - other OdbBackend methods

   def write(self, oid, data, length, type):
        print(f"writing {oid} {length} type {type}")
        return True

repo = pygit2.Repository()
odb = pygit2.Odb()
odb.add_backend(MyOdbBackend(), 1)
repo.set_odb(odb)

test_blob_id = repo.create_blob(b"hello world\n")
print(repo[test_blob_id].data)

But I get a _pygit2.GitError: TLS backend doesn't support certificate locations on calling repo.create_blob(). The built-in backends seem to work fine.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the custom MyOdbBackend.write() example and the failure at repo.create_blob(). Read the OdbBackend and add_backend interfaces plus the related documentation to determine whether write() is supported. Done means the behavior is either implemented and verified with this example or clearly documented with the limitation and error cause.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, python
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.