From 8bde1038e19108ec90f899ce4aff7f31c1e387eb Mon Sep 17 00:00:00 2001 From: Barry Scott Date: Mon, 1 Aug 2016 12:21:11 +0100 Subject: add test to detect the corrupt log - add a second line to commit messages with the "BAD MESSAGE" text - read in the log and confirm that the seond line is not in the log file --- git/test/test_repo.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'git/test/test_repo.py') diff --git a/git/test/test_repo.py b/git/test/test_repo.py index 87887bad..b1a58fd4 100644 --- a/git/test/test_repo.py +++ b/git/test/test_repo.py @@ -775,12 +775,23 @@ class TestRepo(TestBase): new_file_path = os.path.join(rw_dir, "new_file.ext") touch(new_file_path) r.index.add([new_file_path]) - r.index.commit("initial commit") + r.index.commit("initial commit\nBAD MESSAGE 1\n") # Now a branch should be creatable nb = r.create_head('foo') assert nb.is_valid() + with open( new_file_path, 'w' ) as f: + f.write( 'Line 1\n' ) + + r.index.add([new_file_path]) + r.index.commit("add line 1\nBAD MESSAGE 2\n") + + with open( '%s/.git/logs/refs/heads/master' % (rw_dir,), 'r' ) as f: + contents = f.read() + + assert 'BAD MESSAGE' not in contents, 'log is corrupt' + def test_merge_base(self): repo = self.rorepo c1 = 'f6aa8d1' -- cgit v1.2.1 From d8ef023a5bab377764343c954bf453869def4807 Mon Sep 17 00:00:00 2001 From: Barry Scott Date: Mon, 1 Aug 2016 12:29:12 +0100 Subject: fix flake8 problems --- git/test/test_repo.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'git/test/test_repo.py') diff --git a/git/test/test_repo.py b/git/test/test_repo.py index b1a58fd4..48900c26 100644 --- a/git/test/test_repo.py +++ b/git/test/test_repo.py @@ -781,13 +781,13 @@ class TestRepo(TestBase): nb = r.create_head('foo') assert nb.is_valid() - with open( new_file_path, 'w' ) as f: - f.write( 'Line 1\n' ) + with open(new_file_path, 'w') as f: + f.write('Line 1\n') r.index.add([new_file_path]) r.index.commit("add line 1\nBAD MESSAGE 2\n") - with open( '%s/.git/logs/refs/heads/master' % (rw_dir,), 'r' ) as f: + with open('%s/.git/logs/refs/heads/master' % (rw_dir,), 'r') as f: contents = f.read() assert 'BAD MESSAGE' not in contents, 'log is corrupt' -- cgit v1.2.1