| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -672,7 +672,7 @@ def unmerged_blobs(self): | |||
| 672 | 672 | Returns | |
| 673 | 673 | Iterator yielding dict(path : list( tuple( stage, Blob, ...))), being | |
| 674 | 674 | a dictionary associating a path in the index with a list containing | |
| 675 | - stage/blob pairs | ||
| 675 | + sorted stage/blob pairs | ||
| 676 | 676 | ||
| 677 | 677 | Note: | |
| 678 | 678 | Blobs that have been removed in one side simply do not exist in the | |
@@ -684,7 +684,8 @@ def unmerged_blobs(self): | |||
| 684 | 684 | for stage, blob in self.iter_blobs(is_unmerged_blob): | |
| 685 | 685 | path_map.setdefault(blob.path, list()).append((stage, blob)) | |
| 686 | 686 | # END for each unmerged blob | |
| 687 | - | ||
| 687 | + for l in path_map.itervalues(): | ||
| 688 | + l.sort() | ||
| 688 | 689 | return path_map | |
| 689 | 690 | ||
| 690 | 691 | @classmethod | |
@@ -724,7 +725,7 @@ def resolve_blobs(self, iter_blobs): | |||
| 724 | 725 | for blob in iter_blobs: | |
| 725 | 726 | stage_null_key = (blob.path, 0) | |
| 726 | 727 | if stage_null_key in self.entries: | |
| 727 | - raise ValueError( "Blob %r already at stage 0" % blob ) | ||
| 728 | + raise ValueError( "Path %r already exists at stage 0" % blob.path ) | ||
| 728 | 729 | # END assert blob is not stage 0 already | |
| 729 | 730 | ||
| 730 | 731 | # delete all possible stages | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -693,8 +693,9 @@ def init(cls, path=None, mkdir=True, **kwargs): | |||
| 693 | 693 | if mkdir and path and not os.path.exists(path): | |
| 694 | 694 | os.makedirs(path, 0755) | |
| 695 | 695 | ||
| 696 | + # git command automatically chdir into the directory | ||
| 696 | 697 | git = Git(path) | |
| 697 | - output = git.init(path, **kwargs) | ||
| 698 | + output = git.init(**kwargs) | ||
| 698 | 699 | return Repo(path) | |
| 699 | 700 | ||
| 700 | 701 | def clone(self, path, **kwargs): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,6 +9,7 @@ | |||
| 9 | 9 | from git import * | |
| 10 | 10 | from git.utils import join_path_native | |
| 11 | 11 | import tempfile | |
| 12 | + import shutil | ||
| 12 | 13 | ||
| 13 | 14 | class TestRepo(TestBase): | |
| 14 | 15 | ||
@@ -90,17 +91,33 @@ def test_trees(self): | |||
| 90 | 91 | assert num_trees == mc | |
| 91 | 92 | ||
| 92 | 93 | ||
| 93 | - @patch_object(Repo, '__init__') | ||
| 94 | - @patch_object(Git, '_call_process') | ||
| 95 | - def test_init(self, git, repo): | ||
| 96 | - git.return_value = True | ||
| 97 | - repo.return_value = None | ||
| 98 | - | ||
| 99 | - r = Repo.init("repos/foo/bar.git", bare=True) | ||
| 100 | - assert isinstance(r, Repo) | ||
| 101 | - | ||
| 102 | - assert_true(git.called) | ||
| 103 | - assert_true(repo.called) | ||
| 94 | + def test_init(self): | ||
| 95 | + prev_cwd = os.getcwd() | ||
| 96 | + os.chdir(tempfile.gettempdir()) | ||
| 97 | + git_dir_rela = "repos/foo/bar.git" | ||
| 98 | + del_dir_abs = os.path.abspath("repos") | ||
| 99 | + git_dir_abs = os.path.abspath(git_dir_rela) | ||
| 100 | + try: | ||
| 101 | + # with specific path | ||
| 102 | + for path in (git_dir_rela, git_dir_abs): | ||
| 103 | + r = Repo.init(path=path, bare=True) | ||
| 104 | + assert isinstance(r, Repo) | ||
| 105 | + assert r.bare == True | ||
| 106 | + assert os.path.isdir(r.git_dir) | ||
| 107 | + shutil.rmtree(git_dir_abs) | ||
| 108 | + # END for each path | ||
| 109 | + | ||
| 110 | + os.makedirs(git_dir_rela) | ||
| 111 | + os.chdir(git_dir_rela) | ||
| 112 | + r = Repo.init(bare=False) | ||
| 113 | + r.bare == False | ||
| 114 | + finally: | ||
| 115 | + try: | ||
| 116 | + shutil.rmtree(del_dir_abs) | ||
| 117 | + except OSError: | ||
| 118 | + pass | ||
| 119 | + os.chdir(prev_cwd) | ||
| 120 | + # END restore previous state | ||
| 104 | 121 | ||
| 105 | 122 | def test_bare_property(self): | |
| 106 | 123 | self.rorepo.bare | |
| Back | FazBrowse Home | New Git URL |
0 commit comments