| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,6 +20,12 @@ | |||
| 20 | 20 | import time | |
| 21 | 21 | from stat import * | |
| 22 | 22 | ||
| 23 | + from StringIO import StringIO | ||
| 24 | + from gitdb.base import IStream | ||
| 25 | + from git.objects import Blob | ||
| 26 | + from git.index.typ import BaseIndexEntry | ||
| 27 | + | ||
| 28 | + | ||
| 23 | 29 | class TestIndex(TestBase): | |
| 24 | 30 | ||
| 25 | 31 | def __init__(self, *args): | |
@@ -646,6 +652,34 @@ def make_paths(): | |||
| 646 | 652 | for absfile in absfiles: | |
| 647 | 653 | assert os.path.isfile(absfile) | |
| 648 | 654 | ||
| 655 | + @with_rw_repo('HEAD', bare=True) | ||
| 656 | + def test_index_bare_add(self, rw_bare_repo): | ||
| 657 | + # Something is wrong after cloning to a bare repo, reading the | ||
| 658 | + # property rw_bare_repo.working_tree_dir will return '/tmp' | ||
| 659 | + # instead of throwing the Exception we are expecting. This is | ||
| 660 | + # a quick hack to make this test fail when expected. | ||
| 661 | + rw_bare_repo._working_tree_dir = None | ||
| 662 | + contents = 'This is a StringIO file' | ||
| 663 | + filesize = len(contents) | ||
| 664 | + fileobj = StringIO(contents) | ||
| 665 | + filename = 'my-imaginary-file' | ||
| 666 | + istream = rw_bare_repo.odb.store( | ||
| 667 | + IStream(Blob.type, filesize, fileobj)) | ||
| 668 | + entry = BaseIndexEntry((100644, istream.binsha, 0, filename)) | ||
| 669 | + try: | ||
| 670 | + rw_bare_repo.index.add([entry]) | ||
| 671 | + except AssertionError, e: | ||
| 672 | + self.fail("Adding to the index of a bare repo is not allowed.") | ||
| 673 | + | ||
| 674 | + # Adding using a path should still require a non-bare repository. | ||
| 675 | + asserted = False | ||
| 676 | + path = os.path.join('git', 'test', 'test_index.py') | ||
| 677 | + try: | ||
| 678 | + rw_bare_repo.index.add([path]) | ||
| 679 | + except Exception, e: | ||
| 680 | + asserted = "does not have a working tree" in e.message | ||
| 681 | + assert asserted, "Adding using a filename is not correctly asserted." | ||
| 682 | + | ||
| 649 | 683 | ||
| 650 | 684 | @with_rw_repo('HEAD') | |
| 651 | 685 | def test_compare_write_tree(self, rw_repo): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments