Show More
@@ -1886,3 +1886,17 b' def repo_groups(request):' | |||||
1886 | fixture.destroy_repo_group(parent_group) |
|
1886 | fixture.destroy_repo_group(parent_group) | |
1887 |
|
1887 | |||
1888 | return zombie_group, parent_group, child_group |
|
1888 | return zombie_group, parent_group, child_group | |
|
1889 | ||||
|
1890 | ||||
|
1891 | @pytest.fixture(scope="session") | |||
|
1892 | def tmp_path_factory(request): | |||
|
1893 | """Return a :class:`_pytest.tmpdir.TempPathFactory` instance for the test session. | |||
|
1894 | """ | |||
|
1895 | ||||
|
1896 | class TempPathFactory: | |||
|
1897 | ||||
|
1898 | def mktemp(self, basename): | |||
|
1899 | import tempfile | |||
|
1900 | return tempfile.mktemp(basename) | |||
|
1901 | ||||
|
1902 | return TempPathFactory() |
@@ -41,60 +41,41 b' from rhodecode.tests.vcs.conftest import' | |||||
41 | pytestmark = pytest.mark.backends("git") |
|
41 | pytestmark = pytest.mark.backends("git") | |
42 |
|
42 | |||
43 |
|
43 | |||
44 | def repo_path_generator(): |
|
44 | class TestGitRepository(object): | |
45 | """ |
|
|||
46 | Return a different path to be used for cloning repos. |
|
|||
47 | """ |
|
|||
48 | i = 0 |
|
|||
49 | while True: |
|
|||
50 | i += 1 |
|
|||
51 | yield '%s-%d' % (TEST_GIT_REPO_CLONE, i) |
|
|||
52 |
|
||||
53 |
|
||||
54 | REPO_PATH_GENERATOR = repo_path_generator() |
|
|||
55 |
|
||||
56 |
|
||||
57 | class TestGitRepository: |
|
|||
58 |
|
||||
59 | # pylint: disable=protected-access |
|
|||
60 |
|
||||
61 | def __check_for_existing_repo(self): |
|
|||
62 | if os.path.exists(TEST_GIT_REPO_CLONE): |
|
|||
63 | self.fail('Cannot test git clone repo as location %s already ' |
|
|||
64 | 'exists. You should manually remove it first.' |
|
|||
65 | % TEST_GIT_REPO_CLONE) |
|
|||
66 |
|
45 | |||
67 | @pytest.fixture(autouse=True) |
|
46 | @pytest.fixture(autouse=True) | |
68 | def prepare(self, request, baseapp): |
|
47 | def prepare(self, request, baseapp): | |
69 | self.repo = GitRepository(TEST_GIT_REPO, bare=True) |
|
48 | self.repo = GitRepository(TEST_GIT_REPO, bare=True) | |
70 |
|
49 | |||
71 | def get_clone_repo(self): |
|
50 | def get_clone_repo(self, tmp_path_factory): | |
72 | """ |
|
51 | """ | |
73 | Return a non bare clone of the base repo. |
|
52 | Return a non bare clone of the base repo. | |
74 | """ |
|
53 | """ | |
75 | clone_path = next(REPO_PATH_GENERATOR) |
|
54 | clone_path = tmp_path_factory.mktemp('clone-url') | |
76 | repo_clone = GitRepository( |
|
55 | repo_clone = GitRepository( | |
77 | clone_path, create=True, src_url=self.repo.path, bare=False) |
|
56 | clone_path, create=True, src_url=self.repo.path, bare=False) | |
78 |
|
57 | |||
79 | return repo_clone |
|
58 | return repo_clone | |
80 |
|
59 | |||
81 | def get_empty_repo(self, bare=False): |
|
60 | def get_empty_repo(self, tmp_path_factory, bare=False): | |
82 | """ |
|
61 | """ | |
83 | Return a non bare empty repo. |
|
62 | Return a non bare empty repo. | |
84 | """ |
|
63 | """ | |
85 | return GitRepository(next(REPO_PATH_GENERATOR), create=True, bare=bare) |
|
64 | clone_path = tmp_path_factory.mktemp('empty-repo') | |
|
65 | return GitRepository(clone_path, create=True, bare=bare) | |||
86 |
|
66 | |||
87 | def test_wrong_repo_path(self): |
|
67 | def test_wrong_repo_path(self): | |
88 | wrong_repo_path = '/tmp/errorrepo_git' |
|
68 | wrong_repo_path = '/tmp/errorrepo_git' | |
89 | with pytest.raises(RepositoryError): |
|
69 | with pytest.raises(RepositoryError): | |
90 | GitRepository(wrong_repo_path) |
|
70 | GitRepository(wrong_repo_path) | |
91 |
|
71 | |||
92 | def test_repo_clone(self): |
|
72 | def test_repo_clone(self, tmp_path_factory): | |
93 | self.__check_for_existing_repo() |
|
|||
94 | repo = GitRepository(TEST_GIT_REPO) |
|
73 | repo = GitRepository(TEST_GIT_REPO) | |
|
74 | clone_path = tmp_path_factory.mktemp('_') + '_' + TEST_GIT_REPO_CLONE | |||
95 | repo_clone = GitRepository( |
|
75 | repo_clone = GitRepository( | |
96 | TEST_GIT_REPO_CLONE, |
|
76 | clone_path, | |
97 | src_url=TEST_GIT_REPO, create=True, do_workspace_checkout=True) |
|
77 | src_url=TEST_GIT_REPO, create=True, do_workspace_checkout=True) | |
|
78 | ||||
98 | assert len(repo.commit_ids) == len(repo_clone.commit_ids) |
|
79 | assert len(repo.commit_ids) == len(repo_clone.commit_ids) | |
99 | # Checking hashes of commits should be enough |
|
80 | # Checking hashes of commits should be enough | |
100 | for commit in repo.get_commits(): |
|
81 | for commit in repo.get_commits(): | |
@@ -106,9 +87,10 b' class TestGitRepository:' | |||||
106 | GitRepository( |
|
87 | GitRepository( | |
107 | TEST_GIT_REPO_CLONE + '_wo_create', src_url=TEST_GIT_REPO) |
|
88 | TEST_GIT_REPO_CLONE + '_wo_create', src_url=TEST_GIT_REPO) | |
108 |
|
89 | |||
109 | def test_repo_clone_with_update(self): |
|
90 | def test_repo_clone_with_update(self, tmp_path_factory): | |
110 | repo = GitRepository(TEST_GIT_REPO) |
|
91 | repo = GitRepository(TEST_GIT_REPO) | |
111 |
clone_path = TEST_GIT_REPO_CLONE + ' |
|
92 | clone_path = tmp_path_factory.mktemp('_') + '_' + TEST_GIT_REPO_CLONE + '_update' | |
|
93 | ||||
112 | repo_clone = GitRepository( |
|
94 | repo_clone = GitRepository( | |
113 | clone_path, |
|
95 | clone_path, | |
114 | create=True, src_url=TEST_GIT_REPO, do_workspace_checkout=True) |
|
96 | create=True, src_url=TEST_GIT_REPO, do_workspace_checkout=True) | |
@@ -118,9 +100,9 b' class TestGitRepository:' | |||||
118 | fpath = os.path.join(clone_path, 'MANIFEST.in') |
|
100 | fpath = os.path.join(clone_path, 'MANIFEST.in') | |
119 | assert os.path.isfile(fpath) |
|
101 | assert os.path.isfile(fpath) | |
120 |
|
102 | |||
121 | def test_repo_clone_without_update(self): |
|
103 | def test_repo_clone_without_update(self, tmp_path_factory): | |
122 | repo = GitRepository(TEST_GIT_REPO) |
|
104 | repo = GitRepository(TEST_GIT_REPO) | |
123 | clone_path = TEST_GIT_REPO_CLONE + '_without_update' |
|
105 | clone_path = tmp_path_factory.mktemp('_') + '_' + TEST_GIT_REPO_CLONE + '_without_update' | |
124 | repo_clone = GitRepository( |
|
106 | repo_clone = GitRepository( | |
125 | clone_path, |
|
107 | clone_path, | |
126 | create=True, src_url=TEST_GIT_REPO, do_workspace_checkout=False) |
|
108 | create=True, src_url=TEST_GIT_REPO, do_workspace_checkout=False) | |
@@ -131,9 +113,9 b' class TestGitRepository:' | |||||
131 | assert not repo_clone.bare |
|
113 | assert not repo_clone.bare | |
132 | assert not os.path.isfile(fpath) |
|
114 | assert not os.path.isfile(fpath) | |
133 |
|
115 | |||
134 | def test_repo_clone_into_bare_repo(self): |
|
116 | def test_repo_clone_into_bare_repo(self, tmp_path_factory): | |
135 | repo = GitRepository(TEST_GIT_REPO) |
|
117 | repo = GitRepository(TEST_GIT_REPO) | |
136 | clone_path = TEST_GIT_REPO_CLONE + '_bare.git' |
|
118 | clone_path = tmp_path_factory.mktemp('_') + '_' + TEST_GIT_REPO_CLONE + '_bare.git' | |
137 | repo_clone = GitRepository( |
|
119 | repo_clone = GitRepository( | |
138 | clone_path, create=True, src_url=repo.path, bare=True) |
|
120 | clone_path, create=True, src_url=repo.path, bare=True) | |
139 | assert repo_clone.bare |
|
121 | assert repo_clone.bare | |
@@ -275,8 +257,8 b' TODO: To be written...' | |||||
275 | def test_head(self): |
|
257 | def test_head(self): | |
276 | assert self.repo.head == self.repo.get_commit().raw_id |
|
258 | assert self.repo.head == self.repo.get_commit().raw_id | |
277 |
|
259 | |||
278 | def test_checkout_with_create(self): |
|
260 | def test_checkout_with_create(self, tmp_path_factory): | |
279 | repo_clone = self.get_clone_repo() |
|
261 | repo_clone = self.get_clone_repo(tmp_path_factory) | |
280 |
|
262 | |||
281 | new_branch = 'new_branch' |
|
263 | new_branch = 'new_branch' | |
282 | assert repo_clone._current_branch() == 'master' |
|
264 | assert repo_clone._current_branch() == 'master' | |
@@ -288,22 +270,22 b' TODO: To be written...' | |||||
288 | assert set(repo_clone.branches) == {'master', new_branch} |
|
270 | assert set(repo_clone.branches) == {'master', new_branch} | |
289 | assert repo_clone._current_branch() == new_branch |
|
271 | assert repo_clone._current_branch() == new_branch | |
290 |
|
272 | |||
291 | def test_checkout(self): |
|
273 | def test_checkout(self, tmp_path_factory): | |
292 | repo_clone = self.get_clone_repo() |
|
274 | repo_clone = self.get_clone_repo(tmp_path_factory) | |
293 |
|
275 | |||
294 | repo_clone._checkout('new_branch', create=True) |
|
276 | repo_clone._checkout('new_branch', create=True) | |
295 | repo_clone._checkout('master') |
|
277 | repo_clone._checkout('master') | |
296 |
|
278 | |||
297 | assert repo_clone._current_branch() == 'master' |
|
279 | assert repo_clone._current_branch() == 'master' | |
298 |
|
280 | |||
299 | def test_checkout_same_branch(self): |
|
281 | def test_checkout_same_branch(self, tmp_path_factory): | |
300 | repo_clone = self.get_clone_repo() |
|
282 | repo_clone = self.get_clone_repo(tmp_path_factory) | |
301 |
|
283 | |||
302 | repo_clone._checkout('master') |
|
284 | repo_clone._checkout('master') | |
303 | assert repo_clone._current_branch() == 'master' |
|
285 | assert repo_clone._current_branch() == 'master' | |
304 |
|
286 | |||
305 | def test_checkout_branch_already_exists(self): |
|
287 | def test_checkout_branch_already_exists(self, tmp_path_factory): | |
306 | repo_clone = self.get_clone_repo() |
|
288 | repo_clone = self.get_clone_repo(tmp_path_factory) | |
307 |
|
289 | |||
308 | with pytest.raises(RepositoryError): |
|
290 | with pytest.raises(RepositoryError): | |
309 | repo_clone._checkout('master', create=True) |
|
291 | repo_clone._checkout('master', create=True) | |
@@ -316,32 +298,32 b' TODO: To be written...' | |||||
316 | with pytest.raises(RepositoryError): |
|
298 | with pytest.raises(RepositoryError): | |
317 | self.repo._current_branch() |
|
299 | self.repo._current_branch() | |
318 |
|
300 | |||
319 | def test_current_branch_empty_repo(self): |
|
301 | def test_current_branch_empty_repo(self, tmp_path_factory): | |
320 | repo = self.get_empty_repo() |
|
302 | repo = self.get_empty_repo(tmp_path_factory) | |
321 | assert repo._current_branch() is None |
|
303 | assert repo._current_branch() is None | |
322 |
|
304 | |||
323 | def test_local_clone(self): |
|
305 | def test_local_clone(self, tmp_path_factory): | |
324 | clone_path = next(REPO_PATH_GENERATOR) |
|
306 | clone_path = tmp_path_factory.mktemp('test-local-clone') | |
325 | self.repo._local_clone(clone_path, 'master') |
|
307 | self.repo._local_clone(clone_path, 'master') | |
326 | repo_clone = GitRepository(clone_path) |
|
308 | repo_clone = GitRepository(clone_path) | |
327 |
|
309 | |||
328 | assert self.repo.commit_ids == repo_clone.commit_ids |
|
310 | assert self.repo.commit_ids == repo_clone.commit_ids | |
329 |
|
311 | |||
330 | def test_local_clone_with_specific_branch(self): |
|
312 | def test_local_clone_with_specific_branch(self, tmp_path_factory): | |
331 | source_repo = self.get_clone_repo() |
|
313 | source_repo = self.get_clone_repo(tmp_path_factory) | |
332 |
|
314 | |||
333 | # Create a new branch in source repo |
|
315 | # Create a new branch in source repo | |
334 | new_branch_commit = source_repo.commit_ids[-3] |
|
316 | new_branch_commit = source_repo.commit_ids[-3] | |
335 | source_repo._checkout(new_branch_commit) |
|
317 | source_repo._checkout(new_branch_commit) | |
336 | source_repo._checkout('new_branch', create=True) |
|
318 | source_repo._checkout('new_branch', create=True) | |
337 |
|
319 | |||
338 | clone_path = next(REPO_PATH_GENERATOR) |
|
320 | clone_path = tmp_path_factory.mktemp('git-clone-path-1') | |
339 | source_repo._local_clone(clone_path, 'new_branch') |
|
321 | source_repo._local_clone(clone_path, 'new_branch') | |
340 | repo_clone = GitRepository(clone_path) |
|
322 | repo_clone = GitRepository(clone_path) | |
341 |
|
323 | |||
342 | assert source_repo.commit_ids[:-3 + 1] == repo_clone.commit_ids |
|
324 | assert source_repo.commit_ids[:-3 + 1] == repo_clone.commit_ids | |
343 |
|
325 | |||
344 | clone_path = next(REPO_PATH_GENERATOR) |
|
326 | clone_path = tmp_path_factory.mktemp('git-clone-path-2') | |
345 | source_repo._local_clone(clone_path, 'master') |
|
327 | source_repo._local_clone(clone_path, 'master') | |
346 | repo_clone = GitRepository(clone_path) |
|
328 | repo_clone = GitRepository(clone_path) | |
347 |
|
329 | |||
@@ -351,9 +333,9 b' TODO: To be written...' | |||||
351 | with pytest.raises(RepositoryError): |
|
333 | with pytest.raises(RepositoryError): | |
352 | self.repo._local_clone(self.repo.path, 'master') |
|
334 | self.repo._local_clone(self.repo.path, 'master') | |
353 |
|
335 | |||
354 | def test_local_fetch(self): |
|
336 | def test_local_fetch(self, tmp_path_factory): | |
355 | target_repo = self.get_empty_repo() |
|
337 | target_repo = self.get_empty_repo(tmp_path_factory) | |
356 | source_repo = self.get_clone_repo() |
|
338 | source_repo = self.get_clone_repo(tmp_path_factory) | |
357 |
|
339 | |||
358 | # Create a new branch in source repo |
|
340 | # Create a new branch in source repo | |
359 | master_commit = source_repo.commit_ids[-1] |
|
341 | master_commit = source_repo.commit_ids[-1] | |
@@ -367,8 +349,8 b' TODO: To be written...' | |||||
367 | target_repo._local_fetch(source_repo.path, 'master') |
|
349 | target_repo._local_fetch(source_repo.path, 'master') | |
368 | assert target_repo._last_fetch_heads() == [master_commit] |
|
350 | assert target_repo._last_fetch_heads() == [master_commit] | |
369 |
|
351 | |||
370 | def test_local_fetch_from_bare_repo(self): |
|
352 | def test_local_fetch_from_bare_repo(self, tmp_path_factory): | |
371 | target_repo = self.get_empty_repo() |
|
353 | target_repo = self.get_empty_repo(tmp_path_factory) | |
372 | target_repo._local_fetch(self.repo.path, 'master') |
|
354 | target_repo._local_fetch(self.repo.path, 'master') | |
373 |
|
355 | |||
374 | master_commit = self.repo.commit_ids[-1] |
|
356 | master_commit = self.repo.commit_ids[-1] | |
@@ -378,15 +360,15 b' TODO: To be written...' | |||||
378 | with pytest.raises(ValueError): |
|
360 | with pytest.raises(ValueError): | |
379 | self.repo._local_fetch(self.repo.path, 'master') |
|
361 | self.repo._local_fetch(self.repo.path, 'master') | |
380 |
|
362 | |||
381 | def test_local_fetch_branch_does_not_exist(self): |
|
363 | def test_local_fetch_branch_does_not_exist(self, tmp_path_factory): | |
382 | target_repo = self.get_empty_repo() |
|
364 | target_repo = self.get_empty_repo(tmp_path_factory) | |
383 |
|
365 | |||
384 | with pytest.raises(RepositoryError): |
|
366 | with pytest.raises(RepositoryError): | |
385 | target_repo._local_fetch(self.repo.path, 'new_branch') |
|
367 | target_repo._local_fetch(self.repo.path, 'new_branch') | |
386 |
|
368 | |||
387 | def test_local_pull(self): |
|
369 | def test_local_pull(self, tmp_path_factory): | |
388 | target_repo = self.get_empty_repo() |
|
370 | target_repo = self.get_empty_repo(tmp_path_factory) | |
389 | source_repo = self.get_clone_repo() |
|
371 | source_repo = self.get_clone_repo(tmp_path_factory) | |
390 |
|
372 | |||
391 | # Create a new branch in source repo |
|
373 | # Create a new branch in source repo | |
392 | master_commit = source_repo.commit_ids[-1] |
|
374 | master_commit = source_repo.commit_ids[-1] | |
@@ -406,9 +388,9 b' TODO: To be written...' | |||||
406 | with pytest.raises(RepositoryError): |
|
388 | with pytest.raises(RepositoryError): | |
407 | self.repo._local_pull(self.repo.path, 'master') |
|
389 | self.repo._local_pull(self.repo.path, 'master') | |
408 |
|
390 | |||
409 | def test_local_merge(self): |
|
391 | def test_local_merge(self, tmp_path_factory): | |
410 | target_repo = self.get_empty_repo() |
|
392 | target_repo = self.get_empty_repo(tmp_path_factory) | |
411 | source_repo = self.get_clone_repo() |
|
393 | source_repo = self.get_clone_repo(tmp_path_factory) | |
412 |
|
394 | |||
413 | # Create a new branch in source repo |
|
395 | # Create a new branch in source repo | |
414 | master_commit = source_repo.commit_ids[-1] |
|
396 | master_commit = source_repo.commit_ids[-1] | |
@@ -449,8 +431,8 b' TODO: To be written...' | |||||
449 | assert not os.path.exists( |
|
431 | assert not os.path.exists( | |
450 | os.path.join(target_repo.path, '.git', 'MERGE_HEAD')) |
|
432 | os.path.join(target_repo.path, '.git', 'MERGE_HEAD')) | |
451 |
|
433 | |||
452 | def test_local_merge_into_empty_repo(self): |
|
434 | def test_local_merge_into_empty_repo(self, tmp_path_factory): | |
453 | target_repo = self.get_empty_repo() |
|
435 | target_repo = self.get_empty_repo(tmp_path_factory) | |
454 |
|
436 | |||
455 | # This is required as one cannot do a -ff-only merge in an empty repo. |
|
437 | # This is required as one cannot do a -ff-only merge in an empty repo. | |
456 | target_repo._local_fetch(self.repo.path, 'master') |
|
438 | target_repo._local_fetch(self.repo.path, 'master') | |
@@ -464,8 +446,8 b' TODO: To be written...' | |||||
464 | self.repo._local_merge( |
|
446 | self.repo._local_merge( | |
465 | 'merge_message', 'user name', 'user@name.com', None) |
|
447 | 'merge_message', 'user name', 'user@name.com', None) | |
466 |
|
448 | |||
467 | def test_local_push_non_bare(self): |
|
449 | def test_local_push_non_bare(self, tmp_path_factory): | |
468 | target_repo = self.get_empty_repo() |
|
450 | target_repo = self.get_empty_repo(tmp_path_factory) | |
469 |
|
451 | |||
470 | pushed_branch = 'pushed_branch' |
|
452 | pushed_branch = 'pushed_branch' | |
471 | self.repo._local_push('master', target_repo.path, pushed_branch) |
|
453 | self.repo._local_push('master', target_repo.path, pushed_branch) | |
@@ -479,8 +461,8 b' TODO: To be written...' | |||||
479 | assert (target_repo.branches[pushed_branch] == |
|
461 | assert (target_repo.branches[pushed_branch] == | |
480 | self.repo.branches['master']) |
|
462 | self.repo.branches['master']) | |
481 |
|
463 | |||
482 | def test_local_push_bare(self): |
|
464 | def test_local_push_bare(self, tmp_path_factory): | |
483 | target_repo = self.get_empty_repo(bare=True) |
|
465 | target_repo = self.get_empty_repo(tmp_path_factory, bare=True) | |
484 |
|
466 | |||
485 | pushed_branch = 'pushed_branch' |
|
467 | pushed_branch = 'pushed_branch' | |
486 | self.repo._local_push('master', target_repo.path, pushed_branch) |
|
468 | self.repo._local_push('master', target_repo.path, pushed_branch) | |
@@ -494,8 +476,8 b' TODO: To be written...' | |||||
494 | assert (target_repo.branches[pushed_branch] == |
|
476 | assert (target_repo.branches[pushed_branch] == | |
495 | self.repo.branches['master']) |
|
477 | self.repo.branches['master']) | |
496 |
|
478 | |||
497 | def test_local_push_non_bare_target_branch_is_checked_out(self): |
|
479 | def test_local_push_non_bare_target_branch_is_checked_out(self, tmp_path_factory): | |
498 | target_repo = self.get_clone_repo() |
|
480 | target_repo = self.get_clone_repo(tmp_path_factory) | |
499 |
|
481 | |||
500 | pushed_branch = 'pushed_branch' |
|
482 | pushed_branch = 'pushed_branch' | |
501 | # Create a new branch in source repo |
|
483 | # Create a new branch in source repo | |
@@ -515,8 +497,8 b' TODO: To be written...' | |||||
515 | with pytest.raises(RepositoryError): |
|
497 | with pytest.raises(RepositoryError): | |
516 | self.repo._local_push('master', target_repo.path, 'master') |
|
498 | self.repo._local_push('master', target_repo.path, 'master') | |
517 |
|
499 | |||
518 | def test_hooks_can_be_enabled_via_env_variable_for_local_push(self): |
|
500 | def test_hooks_can_be_enabled_via_env_variable_for_local_push(self, tmp_path_factory): | |
519 | target_repo = self.get_empty_repo(bare=True) |
|
501 | target_repo = self.get_empty_repo(tmp_path_factory, bare=True) | |
520 |
|
502 | |||
521 | with mock.patch.object(self.repo, 'run_git_command') as run_mock: |
|
503 | with mock.patch.object(self.repo, 'run_git_command') as run_mock: | |
522 | self.repo._local_push( |
|
504 | self.repo._local_push( | |
@@ -540,8 +522,8 b' TODO: To be written...' | |||||
540 | f.write('\n'.join(script_lines)) |
|
522 | f.write('\n'.join(script_lines)) | |
541 | os.chmod(hook_path, 0o755) |
|
523 | os.chmod(hook_path, 0o755) | |
542 |
|
524 | |||
543 | def test_local_push_does_not_execute_hook(self): |
|
525 | def test_local_push_does_not_execute_hook(self, tmp_path_factory): | |
544 | target_repo = self.get_empty_repo() |
|
526 | target_repo = self.get_empty_repo(tmp_path_factory) | |
545 |
|
527 | |||
546 | pushed_branch = 'pushed_branch' |
|
528 | pushed_branch = 'pushed_branch' | |
547 | self._add_failing_hook(target_repo.path, 'pre-receive') |
|
529 | self._add_failing_hook(target_repo.path, 'pre-receive') | |
@@ -556,8 +538,8 b' TODO: To be written...' | |||||
556 | assert (target_repo.branches[pushed_branch] == |
|
538 | assert (target_repo.branches[pushed_branch] == | |
557 | self.repo.branches['master']) |
|
539 | self.repo.branches['master']) | |
558 |
|
540 | |||
559 | def test_local_push_executes_hook(self): |
|
541 | def test_local_push_executes_hook(self, tmp_path_factory): | |
560 | target_repo = self.get_empty_repo(bare=True) |
|
542 | target_repo = self.get_empty_repo(tmp_path_factory, bare=True) | |
561 | self._add_failing_hook(target_repo.path, 'pre-receive', bare=True) |
|
543 | self._add_failing_hook(target_repo.path, 'pre-receive', bare=True) | |
562 | with pytest.raises(RepositoryError): |
|
544 | with pytest.raises(RepositoryError): | |
563 | self.repo._local_push( |
|
545 | self.repo._local_push( |
@@ -46,6 +46,7 b' class TestVCSOperationsSpecial(object):' | |||||
46 | cmd.execute('git clone', clone_url) |
|
46 | cmd.execute('git clone', clone_url) | |
47 |
|
47 | |||
48 | repo = GitRepository(os.path.join(tmpdir.strpath, empty_repo.repo_name)) |
|
48 | repo = GitRepository(os.path.join(tmpdir.strpath, empty_repo.repo_name)) | |
|
49 | repo._checkout('test', create=True) | |||
49 | repo.in_memory_commit.add(FileNode('file', content='')) |
|
50 | repo.in_memory_commit.add(FileNode('file', content='')) | |
50 | repo.in_memory_commit.commit( |
|
51 | repo.in_memory_commit.commit( | |
51 | message='Commit on branch test', |
|
52 | message='Commit on branch test', |
General Comments 0
You need to be logged in to leave comments.
Login now