| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 590638f commit b377c07
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,13 +32,13 @@ def construct(cls, repo, treeish, paths = []): | |||
| 32 | 32 | def construct_initialize(self, repo, id, text): | |
| 33 | 33 | self.repo = repo | |
| 34 | 34 | self.id = id | |
| 35 | - self.contents = [] | ||
| 35 | + self.contents = {} | ||
| 36 | 36 | self.__baked__ = False | |
| 37 | 37 | ||
| 38 | 38 | for line in text.splitlines(): | |
| 39 | - self.contents.append(self.content_from_string(self.repo, line)) | ||
| 40 | - | ||
| 41 | - self.contents = [c for c in self.contents if c is not None] | ||
| 39 | + obj = self.content_from_string(self.repo, line) | ||
| 40 | + if obj: | ||
| 41 | + self.contents[obj.name] = obj | ||
| 42 | 42 | ||
| 43 | 43 | self.__bake_it__() | |
| 44 | 44 | return self | |
@@ -84,8 +84,7 @@ def __div__(self, file): | |||
| 84 | 84 | Returns | |
| 85 | 85 | ``GitPython.Blob`` or ``GitPython.Tree`` or ``None`` if not found | |
| 86 | 86 | """ | |
| 87 | - contents = [c for c in self.contents if c.name == file] | ||
| 88 | - return contents and contents[0] or None | ||
| 87 | + return self.contents.get(file) | ||
| 89 | 88 | ||
| 90 | 89 | @property | |
| 91 | 90 | def basename(self): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -96,8 +96,8 @@ def test_tree(self, git): | |||
| 96 | 96 | ||
| 97 | 97 | tree = self.repo.tree('master') | |
| 98 | 98 | ||
| 99 | - assert_equal(4, len([c for c in tree.contents if isinstance(c, Blob)])) | ||
| 100 | - assert_equal(3, len([c for c in tree.contents if isinstance(c, Tree)])) | ||
| 99 | + assert_equal(4, len([c for c in tree.contents.values() if isinstance(c, Blob)])) | ||
| 100 | + assert_equal(3, len([c for c in tree.contents.values() if isinstance(c, Tree)])) | ||
| 101 | 101 | ||
| 102 | 102 | assert_true(git.called) | |
| 103 | 103 | assert_equal(git.call_args, (('ls_tree', 'master'), {})) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,7 +18,7 @@ def test_contents_should_cache(self, git): | |||
| 18 | 18 | ||
| 19 | 19 | tree = self.repo.tree('master') | |
| 20 | 20 | ||
| 21 | - child = tree.contents[-1] | ||
| 21 | + child = tree.contents['grit'] | ||
| 22 | 22 | child.contents | |
| 23 | 23 | child.contents | |
| 24 | 24 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments