Skip to content

Commit 1fd07a0

Browse files
committed
test(index): test for gitpython-developers#265
However, it doesn't reproduce on the latest version of GitPython. Maybe it's on an older one.
1 parent 54e27f7 commit 1fd07a0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

git/test/test_index.py

+15
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,11 @@
4444
BaseIndexEntry,
4545
IndexEntry
4646
)
47+
from gitdb.test.lib import with_rw_directory
4748
from git.index.fun import hook_path
4849

50+
import git
51+
4952

5053
class TestIndex(TestBase):
5154

@@ -765,3 +768,15 @@ def test_index_bare_add(self, rw_bare_repo):
765768
except InvalidGitRepositoryError:
766769
asserted = True
767770
assert asserted, "Adding using a filename is not correctly asserted."
771+
772+
@with_rw_directory
773+
def test_index_add_corruption(self, rw_dir):
774+
# Test for https://github.com/gitpython-developers/GitPython/issues/265
775+
repo = git.Repo.clone_from("git://pkgs.fedoraproject.org/GitPython", rw_dir)
776+
assert not repo.is_dirty()
777+
file_path = os.path.join(rw_dir, "GitPython.spec")
778+
open(file_path, 'wb').close()
779+
assert repo.is_dirty()
780+
repo.index.add(['0001-GPG-signature-support-on-commit-object.patch', 'GitPython.spec', '.gitignore', 'sources'])
781+
repo.git.commit(m="committing file")
782+
assert not repo.is_dirty()

0 commit comments

Comments
 (0)