|
| 1 | +# -*- coding: utf-8 -*- |
1 | 2 | from __future__ import absolute_import |
2 | 3 | from __future__ import unicode_literals |
3 | 4 |
|
@@ -162,3 +163,63 @@ def test_get_conflicted_files_unstaged_files(in_merge_conflict): |
162 | 163 | def test_parse_merge_msg_for_conflicts(input, expected_output): |
163 | 164 | ret = git.parse_merge_msg_for_conflicts(input) |
164 | 165 | assert ret == expected_output |
| 166 | + |
| 167 | + |
| 168 | +def test_get_changed_files(): |
| 169 | + files = git.get_changed_files( |
| 170 | + '78c682a1d13ba20e7cb735313b9314a74365cd3a', |
| 171 | + '3387edbb1288a580b37fe25225aa0b856b18ad1a', |
| 172 | + ) |
| 173 | + assert files == ['CHANGELOG.md', 'setup.py'] |
| 174 | + |
| 175 | + # files changed in source but not in origin should not be returned |
| 176 | + files = git.get_changed_files('HEAD~10', 'HEAD') |
| 177 | + assert files == [] |
| 178 | + |
| 179 | + |
| 180 | +@pytest.mark.parametrize( |
| 181 | + ('s', 'expected'), |
| 182 | + ( |
| 183 | + ('foo\0bar\0', ['foo', 'bar']), |
| 184 | + ('foo\0', ['foo']), |
| 185 | + ('', []), |
| 186 | + ('foo', ['foo']), |
| 187 | + ), |
| 188 | +) |
| 189 | +def test_zsplit(s, expected): |
| 190 | + assert git.zsplit(s) == expected |
| 191 | + |
| 192 | + |
| 193 | +@pytest.fixture |
| 194 | +def non_ascii_repo(tmpdir): |
| 195 | + repo = tmpdir.join('repo').ensure_dir() |
| 196 | + with repo.as_cwd(): |
| 197 | + cmd_output('git', 'init', '.') |
| 198 | + cmd_output('git', 'commit', '--allow-empty', '-m', 'initial commit') |
| 199 | + repo.join('интервью').ensure() |
| 200 | + cmd_output('git', 'add', '.') |
| 201 | + cmd_output('git', 'commit', '--allow-empty', '-m', 'initial commit') |
| 202 | + yield repo |
| 203 | + |
| 204 | + |
| 205 | +def test_all_files_non_ascii(non_ascii_repo): |
| 206 | + ret = git.get_all_files() |
| 207 | + assert ret == ['интервью'] |
| 208 | + |
| 209 | + |
| 210 | +def test_staged_files_non_ascii(non_ascii_repo): |
| 211 | + non_ascii_repo.join('интервью').write('hi') |
| 212 | + cmd_output('git', 'add', '.') |
| 213 | + assert git.get_staged_files() == ['интервью'] |
| 214 | + |
| 215 | + |
| 216 | +def test_changed_files_non_ascii(non_ascii_repo): |
| 217 | + ret = git.get_changed_files('HEAD', 'HEAD^') |
| 218 | + assert ret == ['интервью'] |
| 219 | + |
| 220 | + |
| 221 | +def test_get_conflicted_files_non_ascii(in_merge_conflict): |
| 222 | + open('интервью', 'a').close() |
| 223 | + cmd_output('git', 'add', '.') |
| 224 | + ret = git.get_conflicted_files() |
| 225 | + assert ret == {'conflict_file', 'интервью'} |
0 commit comments