| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f62c9b9 commit 4fe5cfa
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -183,7 +183,6 @@ def execute(self, command, | |||
| 183 | 183 | stdout=subprocess.PIPE, | |
| 184 | 184 | **extra | |
| 185 | 185 | ) | |
| 186 | - | ||
| 187 | 186 | if as_process: | |
| 188 | 187 | return self.AutoInterrupt(proc) | |
| 189 | 188 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -127,6 +127,18 @@ def data_stream(self): | |||
| 127 | 127 | proc = self.repo.git.cat_file(self.type, self.id, as_process=True) | |
| 128 | 128 | return utils.ProcessStreamAdapter(proc, "stdout") | |
| 129 | 129 | ||
| 130 | + def stream_data(self, ostream): | ||
| 131 | + """ | ||
| 132 | + Writes our data directly to the given output stream | ||
| 133 | + | ||
| 134 | + ``ostream`` | ||
| 135 | + File object compatible stream object. | ||
| 136 | + | ||
| 137 | + Returns | ||
| 138 | + self | ||
| 139 | + """ | ||
| 140 | + self.repo.git.cat_file(self.type, self.id, output_stream=ostream) | ||
| 141 | + return self | ||
| 130 | 142 | ||
| 131 | 143 | class IndexObject(Object): | |
| 132 | 144 | """ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,12 +4,15 @@ | |||
| 4 | 4 | # This module is part of GitPython and is released under | |
| 5 | 5 | # the BSD License: http://www.opensource.org/licenses/bsd-license.php | |
| 6 | 6 | ||
| 7 | - from test.testlib import * | ||
| 8 | - from git import * | ||
| 9 | 7 | import git.objects.base as base | |
| 10 | 8 | import git.refs as refs | |
| 9 | + import os | ||
| 10 | + | ||
| 11 | + from test.testlib import * | ||
| 12 | + from git import * | ||
| 11 | 13 | from itertools import chain | |
| 12 | 14 | from git.objects.utils import get_object_type_by_name | |
| 15 | + import tempfile | ||
| 13 | 16 | ||
| 14 | 17 | class TestBase(object): | |
| 15 | 18 | ||
@@ -53,6 +56,12 @@ def test_base_object(self): | |||
| 53 | 56 | data_stream = item.data_stream | |
| 54 | 57 | data = data_stream.read() | |
| 55 | 58 | assert data | |
| 59 | + | ||
| 60 | + tmpfile = os.tmpfile() | ||
| 61 | + assert item == item.stream_data(tmpfile) | ||
| 62 | + tmpfile.seek(0) | ||
| 63 | + assert tmpfile.read() == data | ||
| 64 | + # END stream to file directly | ||
| 56 | 65 | # END for each object type to create | |
| 57 | 66 | ||
| 58 | 67 | # each has a unique sha | |
| Back | FazBrowse Home | New Git URL |
0 commit comments