Show More
@@ -98,7 +98,7 b' class GitRemote(object):' | |||
|
98 | 98 | |
|
99 | 99 | def __init__(self, factory): |
|
100 | 100 | self._factory = factory |
|
101 | ||
|
101 | self.peeled_ref_marker = '^{}' | |
|
102 | 102 | self._bulk_methods = { |
|
103 | 103 | "author": self.commit_attribute, |
|
104 | 104 | "date": self.get_object_attrs, |
@@ -279,7 +279,8 b' class GitRemote(object):' | |||
|
279 | 279 | |
|
280 | 280 | @reraise_safe_exceptions |
|
281 | 281 | def clone(self, wire, url, deferred, valid_refs, update_after_clone): |
|
282 | remote_refs = self.fetch(wire, url, apply_refs=False) | |
|
282 | # TODO(marcink): deprecate this method. Last i checked we don't use it anymore | |
|
283 | remote_refs = self.pull(wire, url, apply_refs=False) | |
|
283 | 284 | repo = self._factory.repo(wire) |
|
284 | 285 | if isinstance(valid_refs, list): |
|
285 | 286 | valid_refs = tuple(valid_refs) |
@@ -396,7 +397,7 b' class GitRemote(object):' | |||
|
396 | 397 | return commit.id |
|
397 | 398 | |
|
398 | 399 | @reraise_safe_exceptions |
|
399 |
def |
|
|
400 | def pull(self, wire, url, apply_refs=True, refs=None): | |
|
400 | 401 | if url != 'default' and '://' not in url: |
|
401 | 402 | client = LocalGitClient(url) |
|
402 | 403 | else: |
@@ -431,10 +432,9 b' class GitRemote(object):' | |||
|
431 | 432 | # TODO: johbo: Needs proper test coverage with a git repository |
|
432 | 433 | # that contains a tag object, so that we would end up with |
|
433 | 434 | # a peeled ref at this point. |
|
434 | PEELED_REF_MARKER = '^{}' | |
|
435 | 435 | for k in remote_refs: |
|
436 |
if k.endswith( |
|
|
437 |
log. |
|
|
436 | if k.endswith(self.peeled_ref_marker): | |
|
437 | log.debug("Skipping peeled reference %s", k) | |
|
438 | 438 | continue |
|
439 | 439 | repo[k] = remote_refs[k] |
|
440 | 440 | |
@@ -442,8 +442,6 b' class GitRemote(object):' | |||
|
442 | 442 | # mikhail: explicitly set the head to the last ref. |
|
443 | 443 | repo['HEAD'] = remote_refs[refs[-1]] |
|
444 | 444 | |
|
445 | # TODO: mikhail: should we return remote_refs here to be | |
|
446 | # consistent? | |
|
447 | 445 | else: |
|
448 | 446 | return remote_refs |
|
449 | 447 | |
@@ -453,7 +451,7 b' class GitRemote(object):' | |||
|
453 | 451 | if refs and not isinstance(refs, (list, tuple)): |
|
454 | 452 | refs = [refs] |
|
455 | 453 | |
|
456 | # get remote heads | |
|
454 | # get all remote refs we'll use to fetch later | |
|
457 | 455 | output, __ = self.run_git_command( |
|
458 | 456 | wire, ['ls-remote', url], fail_on_stderr=False, |
|
459 | 457 | _copts=['-c', 'core.askpass=""'], |
@@ -461,9 +459,16 b' class GitRemote(object):' | |||
|
461 | 459 | |
|
462 | 460 | remote_refs = collections.OrderedDict() |
|
463 | 461 | fetch_refs = [] |
|
462 | ||
|
464 | 463 | for ref_line in output.splitlines(): |
|
465 | 464 | sha, ref = ref_line.split('\t') |
|
466 | 465 | sha = sha.strip() |
|
466 | if ref in remote_refs: | |
|
467 | # duplicate, skip | |
|
468 | continue | |
|
469 | if ref.endswith(self.peeled_ref_marker): | |
|
470 | log.debug("Skipping peeled reference %s", ref) | |
|
471 | continue | |
|
467 | 472 | remote_refs[ref] = sha |
|
468 | 473 | |
|
469 | 474 | if refs and sha in refs: |
@@ -472,12 +477,12 b' class GitRemote(object):' | |||
|
472 | 477 | elif not refs: |
|
473 | 478 | fetch_refs.append('{}:{}'.format(ref, ref)) |
|
474 | 479 | |
|
475 | fetch_refs.append('{}:{}'.format(ref, ref)) | |
|
476 | ||
|
477 | _out, _err = self.run_git_command( | |
|
478 |
|
|
|
479 | _copts=['-c', 'core.askpass=""'], | |
|
480 | extra_env={'GIT_TERMINAL_PROMPT': '0'}) | |
|
480 | if fetch_refs: | |
|
481 | _out, _err = self.run_git_command( | |
|
482 | wire, ['fetch', url, '--prune', '--'] + fetch_refs, | |
|
483 | fail_on_stderr=False, | |
|
484 | _copts=['-c', 'core.askpass=""'], | |
|
485 | extra_env={'GIT_TERMINAL_PROMPT': '0'}) | |
|
481 | 486 | |
|
482 | 487 | return remote_refs |
|
483 | 488 |
@@ -61,7 +61,7 b' class TestGitFetch(object):' | |||
|
61 | 61 | |
|
62 | 62 | with patch('dulwich.client.LocalGitClient.fetch') as mock_fetch: |
|
63 | 63 | mock_fetch.side_effect = side_effect |
|
64 |
self.remote_git. |
|
|
64 | self.remote_git.pull(wire=None, url='/tmp/', apply_refs=False) | |
|
65 | 65 | determine_wants = self.mock_repo.object_store.determine_wants_all |
|
66 | 66 | determine_wants.assert_called_once_with(SAMPLE_REFS) |
|
67 | 67 | |
@@ -78,7 +78,7 b' class TestGitFetch(object):' | |||
|
78 | 78 | |
|
79 | 79 | with patch('dulwich.client.LocalGitClient.fetch') as mock_fetch: |
|
80 | 80 | mock_fetch.side_effect = side_effect |
|
81 |
self.remote_git. |
|
|
81 | self.remote_git.pull( | |
|
82 | 82 | wire=None, url='/tmp/', apply_refs=False, |
|
83 | 83 | refs=selected_refs.keys()) |
|
84 | 84 | determine_wants = self.mock_repo.object_store.determine_wants_all |
General Comments 0
You need to be logged in to leave comments.
Login now