index: write blobs via git hash-object, not gitdb's odb.store by caroescm · Pull Request #2209 · gitpython-developers/GitPython · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion git/db.py
16 changes: 15 additions & 1 deletion test/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,30 @@
# This module is part of GitPython and is released under the
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/

from io import BytesIO
import os.path as osp
from unittest import mock

from gitdb import IStream
from gitdb.db import LooseObjectDB
from gitdb.typ import str_blob_type

from git.db import GitCmdObjectDB
from git.exc import BadObject
from git.util import bin_to_hex

from test.lib import TestBase
from test.lib import TestBase, with_rw_repo


class TestDB(TestBase):
@with_rw_repo("HEAD")
def test_store_uses_hash_object(self, rw_repo):
data = b"hello world"
with mock.patch.object(LooseObjectDB, "store", side_effect=AssertionError("unexpected loose-object write")):
istream = rw_repo.odb.store(IStream(str_blob_type, len(data), BytesIO(data)))

assert rw_repo.odb.stream(istream.binsha).read() == data

def test_base(self):
gdb = GitCmdObjectDB(osp.join(self.rorepo.git_dir, "objects"), self.rorepo.git)

Expand Down
3 changes: 2 additions & 1 deletion test/test_refs.py
Loading