Show More
@@ -66,6 +66,7 b' class TestCreatePullRequestApi(object):' | |||||
66 | expected_message = "Created new pull request `{title}`".format( |
|
66 | expected_message = "Created new pull request `{title}`".format( | |
67 | title=data['title']) |
|
67 | title=data['title']) | |
68 | result = response.json |
|
68 | result = response.json | |
|
69 | assert result['error'] == None | |||
69 | assert result['result']['msg'] == expected_message |
|
70 | assert result['result']['msg'] == expected_message | |
70 | pull_request_id = result['result']['pull_request_id'] |
|
71 | pull_request_id = result['result']['pull_request_id'] | |
71 | pull_request = PullRequestModel().get(pull_request_id) |
|
72 | pull_request = PullRequestModel().get(pull_request_id) | |
@@ -88,6 +89,7 b' class TestCreatePullRequestApi(object):' | |||||
88 | expected_message = "Created new pull request `{title}`".format( |
|
89 | expected_message = "Created new pull request `{title}`".format( | |
89 | title=data['title']) |
|
90 | title=data['title']) | |
90 | result = response.json |
|
91 | result = response.json | |
|
92 | assert result['error'] == None | |||
91 | assert result['result']['msg'] == expected_message |
|
93 | assert result['result']['msg'] == expected_message | |
92 | pull_request_id = result['result']['pull_request_id'] |
|
94 | pull_request_id = result['result']['pull_request_id'] | |
93 | pull_request = PullRequestModel().get(pull_request_id) |
|
95 | pull_request = PullRequestModel().get(pull_request_id) | |
@@ -127,6 +129,7 b' class TestCreatePullRequestApi(object):' | |||||
127 | expected_message = "Created new pull request `{title}`".format( |
|
129 | expected_message = "Created new pull request `{title}`".format( | |
128 | title=data['title']) |
|
130 | title=data['title']) | |
129 | result = response.json |
|
131 | result = response.json | |
|
132 | assert result['error'] == None | |||
130 | assert result['result']['msg'] == expected_message |
|
133 | assert result['result']['msg'] == expected_message | |
131 | pull_request_id = result['result']['pull_request_id'] |
|
134 | pull_request_id = result['result']['pull_request_id'] | |
132 | pull_request = PullRequestModel().get(pull_request_id) |
|
135 | pull_request = PullRequestModel().get(pull_request_id) | |
@@ -170,6 +173,7 b' class TestCreatePullRequestApi(object):' | |||||
170 | expected_message = "Created new pull request `{title}`".format( |
|
173 | expected_message = "Created new pull request `{title}`".format( | |
171 | title=data['title']) |
|
174 | title=data['title']) | |
172 | result = response.json |
|
175 | result = response.json | |
|
176 | assert result['error'] == None | |||
173 | assert result['result']['msg'] == expected_message |
|
177 | assert result['result']['msg'] == expected_message | |
174 | pull_request_id = result['result']['pull_request_id'] |
|
178 | pull_request_id = result['result']['pull_request_id'] | |
175 | pull_request = PullRequestModel().get(pull_request_id) |
|
179 | pull_request = PullRequestModel().get(pull_request_id) |
@@ -123,7 +123,7 b' def create_repo(form_data, cur_user):' | |||||
123 | 'enable_downloads', defs.get('repo_enable_downloads')) |
|
123 | 'enable_downloads', defs.get('repo_enable_downloads')) | |
124 |
|
124 | |||
125 | try: |
|
125 | try: | |
126 |
|
|
126 | RepoModel()._create_repo( | |
127 | repo_name=repo_name_full, |
|
127 | repo_name=repo_name_full, | |
128 | repo_type=repo_type, |
|
128 | repo_type=repo_type, | |
129 | description=description, |
|
129 | description=description, |
@@ -58,13 +58,13 b' class GitRepository(BaseRepository):' | |||||
58 | contact = BaseRepository.DEFAULT_CONTACT |
|
58 | contact = BaseRepository.DEFAULT_CONTACT | |
59 |
|
59 | |||
60 | def __init__(self, repo_path, config=None, create=False, src_url=None, |
|
60 | def __init__(self, repo_path, config=None, create=False, src_url=None, | |
61 |
|
|
61 | do_workspace_checkout=False, with_wire=None, bare=False): | |
62 |
|
62 | |||
63 | self.path = safe_str(os.path.abspath(repo_path)) |
|
63 | self.path = safe_str(os.path.abspath(repo_path)) | |
64 | self.config = config if config else self.get_default_config() |
|
64 | self.config = config if config else self.get_default_config() | |
65 | self.with_wire = with_wire |
|
65 | self.with_wire = with_wire | |
66 |
|
66 | |||
67 |
self._init_repo(create, src_url, |
|
67 | self._init_repo(create, src_url, do_workspace_checkout, bare) | |
68 |
|
68 | |||
69 | # caches |
|
69 | # caches | |
70 | self._commit_ids = {} |
|
70 | self._commit_ids = {} | |
@@ -145,24 +145,36 b' class GitRepository(BaseRepository):' | |||||
145 | pass |
|
145 | pass | |
146 | return False |
|
146 | return False | |
147 |
|
147 | |||
148 |
def _init_repo(self, create, src_url=None, |
|
148 | def _init_repo(self, create, src_url=None, do_workspace_checkout=False, | |
149 | bare=False): |
|
149 | bare=False): | |
150 | if create and os.path.exists(self.path): |
|
150 | if create and os.path.exists(self.path): | |
151 | raise RepositoryError( |
|
151 | raise RepositoryError( | |
152 | "Cannot create repository at %s, location already exist" |
|
152 | "Cannot create repository at %s, location already exist" | |
153 | % self.path) |
|
153 | % self.path) | |
154 |
|
154 | |||
|
155 | if bare and do_workspace_checkout: | |||
|
156 | raise RepositoryError("Cannot update a bare repository") | |||
155 | try: |
|
157 | try: | |
156 | if create and src_url: |
|
158 | ||
|
159 | if src_url: | |||
|
160 | # check URL before any actions | |||
157 | GitRepository.check_url(src_url, self.config) |
|
161 | GitRepository.check_url(src_url, self.config) | |
158 | self.clone(src_url, update_after_clone, bare) |
|
162 | ||
159 |
|
|
163 | if create: | |
160 | os.makedirs(self.path, mode=0755) |
|
164 | os.makedirs(self.path, mode=0755) | |
161 |
|
165 | |||
162 | if bare: |
|
166 | if bare: | |
163 | self._remote.init_bare() |
|
167 | self._remote.init_bare() | |
164 | else: |
|
168 | else: | |
165 | self._remote.init() |
|
169 | self._remote.init() | |
|
170 | ||||
|
171 | if src_url and bare: | |||
|
172 | # bare repository only allows a fetch and checkout is not allowed | |||
|
173 | self.fetch(src_url, commit_ids=None) | |||
|
174 | elif src_url: | |||
|
175 | self.pull(src_url, commit_ids=None, | |||
|
176 | update_after=do_workspace_checkout) | |||
|
177 | ||||
166 | else: |
|
178 | else: | |
167 | if not self._remote.assert_correct_path(): |
|
179 | if not self._remote.assert_correct_path(): | |
168 | raise RepositoryError( |
|
180 | raise RepositoryError( | |
@@ -630,49 +642,27 b' class GitRepository(BaseRepository):' | |||||
630 | """ |
|
642 | """ | |
631 | return GitInMemoryCommit(self) |
|
643 | return GitInMemoryCommit(self) | |
632 |
|
644 | |||
633 |
def |
|
645 | def pull(self, url, commit_ids=None, update_after=False): | |
634 | """ |
|
646 | """ | |
635 |
|
|
647 | Pull changes from external location. Pull is different in GIT | |
636 |
|
648 | that fetch since it's doing a checkout | ||
637 | :param update_after_clone: If set to ``False``, git won't checkout |
|
|||
638 | working directory |
|
|||
639 | :param bare: If set to ``True``, repository would be cloned into |
|
|||
640 | *bare* git repository (no working directory at all). |
|
|||
641 | """ |
|
|||
642 | # init_bare and init expect empty dir created to proceed |
|
|||
643 | if not os.path.exists(self.path): |
|
|||
644 | os.mkdir(self.path) |
|
|||
645 |
|
|
649 | ||
646 | if bare: |
|
650 | :param commit_ids: Optional. Can be set to a list of commit ids | |
647 | self._remote.init_bare() |
|
651 | which shall be pulled from the other repository. | |
648 | else: |
|
|||
649 | self._remote.init() |
|
|||
650 |
|
||||
651 | deferred = '^{}' |
|
|||
652 | valid_refs = ('refs/heads', 'refs/tags', 'HEAD') |
|
|||
653 |
|
||||
654 | return self._remote.clone( |
|
|||
655 | url, deferred, valid_refs, update_after_clone) |
|
|||
656 |
|
||||
657 | def pull(self, url, commit_ids=None): |
|
|||
658 |
|
|
652 | """ | |
659 | Tries to pull changes from external location. We use fetch here since |
|
653 | refs = None | |
660 | pull in get does merges and we want to be compatible with hg backend so |
|
654 | if commit_ids is not None: | |
661 | pull == fetch in this case |
|
655 | remote_refs = self._remote.get_remote_refs(url) | |
662 | """ |
|
656 | refs = [ref for ref in remote_refs if remote_refs[ref] in commit_ids] | |
663 | self.fetch(url, commit_ids=commit_ids) |
|
657 | self._remote.pull(url, refs=refs, update_after=update_after) | |
|
658 | self._remote.invalidate_vcs_cache() | |||
664 |
|
659 | |||
665 | def fetch(self, url, commit_ids=None): |
|
660 | def fetch(self, url, commit_ids=None): | |
666 | """ |
|
661 | """ | |
667 |
|
|
662 | Fetch all git objects from external location. | |
668 | """ |
|
663 | """ | |
669 | refs = None |
|
664 | self._remote.sync_fetch(url, refs=commit_ids) | |
670 |
|
665 | self._remote.invalidate_vcs_cache() | ||
671 | if commit_ids is not None: |
|
|||
672 | remote_refs = self._remote.get_remote_refs(url) |
|
|||
673 | refs = [ |
|
|||
674 | ref for ref in remote_refs if remote_refs[ref] in commit_ids] |
|
|||
675 | self._remote.fetch(url, refs=refs) |
|
|||
676 |
|
666 | |||
677 | def push(self, url): |
|
667 | def push(self, url): | |
678 | refs = None |
|
668 | refs = None |
@@ -57,7 +57,7 b' class MercurialRepository(BaseRepository' | |||||
57 | DEFAULT_BRANCH_NAME = 'default' |
|
57 | DEFAULT_BRANCH_NAME = 'default' | |
58 |
|
58 | |||
59 | def __init__(self, repo_path, config=None, create=False, src_url=None, |
|
59 | def __init__(self, repo_path, config=None, create=False, src_url=None, | |
60 |
|
|
60 | do_workspace_checkout=False, with_wire=None, bare=False): | |
61 | """ |
|
61 | """ | |
62 | Raises RepositoryError if repository could not be find at the given |
|
62 | Raises RepositoryError if repository could not be find at the given | |
63 | ``repo_path``. |
|
63 | ``repo_path``. | |
@@ -67,8 +67,9 b' class MercurialRepository(BaseRepository' | |||||
67 | :param create=False: if set to True, would try to create repository if |
|
67 | :param create=False: if set to True, would try to create repository if | |
68 | it does not exist rather than raising exception |
|
68 | it does not exist rather than raising exception | |
69 | :param src_url=None: would try to clone repository from given location |
|
69 | :param src_url=None: would try to clone repository from given location | |
70 |
:param |
|
70 | :param do_workspace_checkout=False: sets update of working copy after | |
71 | making a clone |
|
71 | making a clone | |
|
72 | :param bare: not used, compatible with other VCS | |||
72 | """ |
|
73 | """ | |
73 |
|
74 | |||
74 | self.path = safe_str(os.path.abspath(repo_path)) |
|
75 | self.path = safe_str(os.path.abspath(repo_path)) | |
@@ -79,7 +80,7 b' class MercurialRepository(BaseRepository' | |||||
79 | default=[('extensions', 'largefiles', '1')]) |
|
80 | default=[('extensions', 'largefiles', '1')]) | |
80 | self.with_wire = with_wire |
|
81 | self.with_wire = with_wire | |
81 |
|
82 | |||
82 |
self._init_repo(create, src_url, |
|
83 | self._init_repo(create, src_url, do_workspace_checkout) | |
83 |
|
84 | |||
84 | # caches |
|
85 | # caches | |
85 | self._commit_ids = {} |
|
86 | self._commit_ids = {} | |
@@ -328,7 +329,7 b' class MercurialRepository(BaseRepository' | |||||
328 | def is_valid_repository(path): |
|
329 | def is_valid_repository(path): | |
329 | return os.path.isdir(os.path.join(path, '.hg')) |
|
330 | return os.path.isdir(os.path.join(path, '.hg')) | |
330 |
|
331 | |||
331 |
def _init_repo(self, create, src_url=None, |
|
332 | def _init_repo(self, create, src_url=None, do_workspace_checkout=False): | |
332 | """ |
|
333 | """ | |
333 | Function will check for mercurial repository in given path. If there |
|
334 | Function will check for mercurial repository in given path. If there | |
334 | is no repository in that path it will raise an exception unless |
|
335 | is no repository in that path it will raise an exception unless | |
@@ -337,7 +338,7 b' class MercurialRepository(BaseRepository' | |||||
337 |
|
338 | |||
338 | If `src_url` is given, would try to clone repository from the |
|
339 | If `src_url` is given, would try to clone repository from the | |
339 | location at given clone_point. Additionally it'll make update to |
|
340 | location at given clone_point. Additionally it'll make update to | |
340 |
working copy accordingly to ` |
|
341 | working copy accordingly to `do_workspace_checkout` flag. | |
341 | """ |
|
342 | """ | |
342 | if create and os.path.exists(self.path): |
|
343 | if create and os.path.exists(self.path): | |
343 | raise RepositoryError( |
|
344 | raise RepositoryError( | |
@@ -348,7 +349,7 b' class MercurialRepository(BaseRepository' | |||||
348 | url = str(self._get_url(src_url)) |
|
349 | url = str(self._get_url(src_url)) | |
349 | MercurialRepository.check_url(url, self.config) |
|
350 | MercurialRepository.check_url(url, self.config) | |
350 |
|
351 | |||
351 |
self._remote.clone(url, self.path, |
|
352 | self._remote.clone(url, self.path, do_workspace_checkout) | |
352 |
|
353 | |||
353 | # Don't try to create if we've already cloned repo |
|
354 | # Don't try to create if we've already cloned repo | |
354 | create = False |
|
355 | create = False | |
@@ -538,7 +539,7 b' class MercurialRepository(BaseRepository' | |||||
538 |
|
539 | |||
539 | def pull(self, url, commit_ids=None): |
|
540 | def pull(self, url, commit_ids=None): | |
540 | """ |
|
541 | """ | |
541 |
|
|
542 | Pull changes from external location. | |
542 |
|
543 | |||
543 | :param commit_ids: Optional. Can be set to a list of commit ids |
|
544 | :param commit_ids: Optional. Can be set to a list of commit ids | |
544 | which shall be pulled from the other repository. |
|
545 | which shall be pulled from the other repository. | |
@@ -547,6 +548,12 b' class MercurialRepository(BaseRepository' | |||||
547 | self._remote.pull(url, commit_ids=commit_ids) |
|
548 | self._remote.pull(url, commit_ids=commit_ids) | |
548 | self._remote.invalidate_vcs_cache() |
|
549 | self._remote.invalidate_vcs_cache() | |
549 |
|
550 | |||
|
551 | def fetch(self, url, commit_ids=None): | |||
|
552 | """ | |||
|
553 | Backward compatibility with GIT fetch==pull | |||
|
554 | """ | |||
|
555 | return self.pull(url, commit_ids=commit_ids) | |||
|
556 | ||||
550 | def push(self, url): |
|
557 | def push(self, url): | |
551 | url = self._get_url(url) |
|
558 | url = self._get_url(url) | |
552 | self._remote.sync_push(url) |
|
559 | self._remote.sync_push(url) |
@@ -68,7 +68,7 b' class SubversionRepository(base.BaseRepo' | |||||
68 | contact = base.BaseRepository.DEFAULT_CONTACT |
|
68 | contact = base.BaseRepository.DEFAULT_CONTACT | |
69 | description = base.BaseRepository.DEFAULT_DESCRIPTION |
|
69 | description = base.BaseRepository.DEFAULT_DESCRIPTION | |
70 |
|
70 | |||
71 | def __init__(self, repo_path, config=None, create=False, src_url=None, |
|
71 | def __init__(self, repo_path, config=None, create=False, src_url=None, bare=False, | |
72 | **kwargs): |
|
72 | **kwargs): | |
73 | self.path = safe_str(os.path.abspath(repo_path)) |
|
73 | self.path = safe_str(os.path.abspath(repo_path)) | |
74 | self.config = config if config else self.get_default_config() |
|
74 | self.config = config if config else self.get_default_config() |
@@ -399,7 +399,7 b' class ScmModel(BaseModel):' | |||||
399 | repo_name = dbrepo.repo_name |
|
399 | repo_name = dbrepo.repo_name | |
400 | try: |
|
400 | try: | |
401 | # TODO: we need to make sure those operations call proper hooks ! |
|
401 | # TODO: we need to make sure those operations call proper hooks ! | |
402 |
repo. |
|
402 | repo.fetch(remote_uri) | |
403 |
|
403 | |||
404 | self.mark_for_invalidation(repo_name) |
|
404 | self.mark_for_invalidation(repo_name) | |
405 | except Exception: |
|
405 | except Exception: |
@@ -581,7 +581,7 b' class Backend(object):' | |||||
581 |
|
581 | |||
582 | def create_repo( |
|
582 | def create_repo( | |
583 | self, commits=None, number_of_commits=0, heads=None, |
|
583 | self, commits=None, number_of_commits=0, heads=None, | |
584 | name_suffix=u'', **kwargs): |
|
584 | name_suffix=u'', bare=False, **kwargs): | |
585 | """ |
|
585 | """ | |
586 | Create a repository and record it for later cleanup. |
|
586 | Create a repository and record it for later cleanup. | |
587 |
|
587 | |||
@@ -591,16 +591,17 b' class Backend(object):' | |||||
591 | commits will be added to the new repository. |
|
591 | commits will be added to the new repository. | |
592 | :param heads: Optional. Can be set to a sequence of of commit |
|
592 | :param heads: Optional. Can be set to a sequence of of commit | |
593 | names which shall be pulled in from the master repository. |
|
593 | names which shall be pulled in from the master repository. | |
594 |
|
594 | :param name_suffix: adds special suffix to generated repo name | ||
|
595 | :param bare: set a repo as bare (no checkout) | |||
595 | """ |
|
596 | """ | |
596 | self.repo_name = self._next_repo_name() + name_suffix |
|
597 | self.repo_name = self._next_repo_name() + name_suffix | |
597 | repo = self._fixture.create_repo( |
|
598 | repo = self._fixture.create_repo( | |
598 | self.repo_name, repo_type=self.alias, **kwargs) |
|
599 | self.repo_name, repo_type=self.alias, bare=bare, **kwargs) | |
599 | self._cleanup_repos.append(repo.repo_name) |
|
600 | self._cleanup_repos.append(repo.repo_name) | |
600 |
|
601 | |||
601 | commits = commits or [ |
|
602 | commits = commits or [ | |
602 | {'message': 'Commit %s of %s' % (x, self.repo_name)} |
|
603 | {'message': 'Commit %s of %s' % (x, self.repo_name)} | |
603 |
for x in |
|
604 | for x in range(number_of_commits)] | |
604 | self._add_commits_to_repo(repo.scm_instance(), commits) |
|
605 | self._add_commits_to_repo(repo.scm_instance(), commits) | |
605 | if heads: |
|
606 | if heads: | |
606 | self.pull_heads(repo, heads) |
|
607 | self.pull_heads(repo, heads) | |
@@ -773,14 +774,15 b' class VcsBackend(object):' | |||||
773 | """ |
|
774 | """ | |
774 | return get_backend(self.alias) |
|
775 | return get_backend(self.alias) | |
775 |
|
776 | |||
776 |
def create_repo(self, commits=None, number_of_commits=0, _clone_repo=None |
|
777 | def create_repo(self, commits=None, number_of_commits=0, _clone_repo=None, | |
|
778 | bare=False): | |||
777 | repo_name = self._next_repo_name() |
|
779 | repo_name = self._next_repo_name() | |
778 | self._repo_path = get_new_dir(repo_name) |
|
780 | self._repo_path = get_new_dir(repo_name) | |
779 | repo_class = get_backend(self.alias) |
|
781 | repo_class = get_backend(self.alias) | |
780 | src_url = None |
|
782 | src_url = None | |
781 | if _clone_repo: |
|
783 | if _clone_repo: | |
782 | src_url = _clone_repo.path |
|
784 | src_url = _clone_repo.path | |
783 | repo = repo_class(self._repo_path, create=True, src_url=src_url) |
|
785 | repo = repo_class(self._repo_path, create=True, src_url=src_url, bare=bare) | |
784 | self._cleanup_repos.append(repo) |
|
786 | self._cleanup_repos.append(repo) | |
785 |
|
787 | |||
786 | commits = commits or [ |
|
788 | commits = commits or [ | |
@@ -1158,13 +1160,13 b' class UserUtility(object):' | |||||
1158 | return repo_group |
|
1160 | return repo_group | |
1159 |
|
1161 | |||
1160 | def create_repo(self, owner=TEST_USER_ADMIN_LOGIN, parent=None, |
|
1162 | def create_repo(self, owner=TEST_USER_ADMIN_LOGIN, parent=None, | |
1161 | auto_cleanup=True, repo_type='hg'): |
|
1163 | auto_cleanup=True, repo_type='hg', bare=False): | |
1162 | repo_name = "{prefix}_repository_{count}".format( |
|
1164 | repo_name = "{prefix}_repository_{count}".format( | |
1163 | prefix=self._test_name, |
|
1165 | prefix=self._test_name, | |
1164 | count=len(self.repos_ids)) |
|
1166 | count=len(self.repos_ids)) | |
1165 |
|
1167 | |||
1166 | repository = self.fixture.create_repo( |
|
1168 | repository = self.fixture.create_repo( | |
1167 | repo_name, cur_user=owner, repo_group=parent, repo_type=repo_type) |
|
1169 | repo_name, cur_user=owner, repo_group=parent, repo_type=repo_type, bare=bare) | |
1168 | if auto_cleanup: |
|
1170 | if auto_cleanup: | |
1169 | self.repos_ids.append(repository.repo_id) |
|
1171 | self.repos_ids.append(repository.repo_id) | |
1170 | return repository |
|
1172 | return repository |
@@ -94,7 +94,7 b' class TestGitRepository:' | |||||
94 | repo = GitRepository(TEST_GIT_REPO) |
|
94 | repo = GitRepository(TEST_GIT_REPO) | |
95 | repo_clone = GitRepository( |
|
95 | repo_clone = GitRepository( | |
96 | TEST_GIT_REPO_CLONE, |
|
96 | TEST_GIT_REPO_CLONE, | |
97 |
src_url=TEST_GIT_REPO, create=True, |
|
97 | src_url=TEST_GIT_REPO, create=True, do_workspace_checkout=True) | |
98 | assert len(repo.commit_ids) == len(repo_clone.commit_ids) |
|
98 | assert len(repo.commit_ids) == len(repo_clone.commit_ids) | |
99 | # Checking hashes of commits should be enough |
|
99 | # Checking hashes of commits should be enough | |
100 | for commit in repo.get_commits(): |
|
100 | for commit in repo.get_commits(): | |
@@ -111,7 +111,7 b' class TestGitRepository:' | |||||
111 | clone_path = TEST_GIT_REPO_CLONE + '_with_update' |
|
111 | clone_path = TEST_GIT_REPO_CLONE + '_with_update' | |
112 | repo_clone = GitRepository( |
|
112 | repo_clone = GitRepository( | |
113 | clone_path, |
|
113 | clone_path, | |
114 |
create=True, src_url=TEST_GIT_REPO, |
|
114 | create=True, src_url=TEST_GIT_REPO, do_workspace_checkout=True) | |
115 | assert len(repo.commit_ids) == len(repo_clone.commit_ids) |
|
115 | assert len(repo.commit_ids) == len(repo_clone.commit_ids) | |
116 |
|
116 | |||
117 | # check if current workdir was updated |
|
117 | # check if current workdir was updated | |
@@ -123,7 +123,7 b' class TestGitRepository:' | |||||
123 | clone_path = TEST_GIT_REPO_CLONE + '_without_update' |
|
123 | clone_path = TEST_GIT_REPO_CLONE + '_without_update' | |
124 | repo_clone = GitRepository( |
|
124 | repo_clone = GitRepository( | |
125 | clone_path, |
|
125 | clone_path, | |
126 |
create=True, src_url=TEST_GIT_REPO, |
|
126 | create=True, src_url=TEST_GIT_REPO, do_workspace_checkout=False) | |
127 | assert len(repo.commit_ids) == len(repo_clone.commit_ids) |
|
127 | assert len(repo.commit_ids) == len(repo_clone.commit_ids) | |
128 | # check if current workdir was *NOT* updated |
|
128 | # check if current workdir was *NOT* updated | |
129 | fpath = os.path.join(clone_path, 'MANIFEST.in') |
|
129 | fpath = os.path.join(clone_path, 'MANIFEST.in') | |
@@ -153,7 +153,7 b' class TestGitRepository:' | |||||
153 | # Note: This is a git specific part of the API, it's only implemented |
|
153 | # Note: This is a git specific part of the API, it's only implemented | |
154 | # by the git backend. |
|
154 | # by the git backend. | |
155 | source_repo = vcsbackend_git.repo |
|
155 | source_repo = vcsbackend_git.repo | |
156 | target_repo = vcsbackend_git.create_repo() |
|
156 | target_repo = vcsbackend_git.create_repo(bare=True) | |
157 | target_repo.fetch(source_repo.path) |
|
157 | target_repo.fetch(source_repo.path) | |
158 | # Note: Get a fresh instance, avoids caching trouble |
|
158 | # Note: Get a fresh instance, avoids caching trouble | |
159 | target_repo = vcsbackend_git.backend(target_repo.path) |
|
159 | target_repo = vcsbackend_git.backend(target_repo.path) | |
@@ -162,8 +162,7 b' class TestGitRepository:' | |||||
162 | def test_commit_ids(self): |
|
162 | def test_commit_ids(self): | |
163 | # there are 112 commits (by now) |
|
163 | # there are 112 commits (by now) | |
164 | # so we can assume they would be available from now on |
|
164 | # so we can assume they would be available from now on | |
165 | subset = set([ |
|
165 | subset = {'c1214f7e79e02fc37156ff215cd71275450cffc3', | |
166 | 'c1214f7e79e02fc37156ff215cd71275450cffc3', |
|
|||
167 | '38b5fe81f109cb111f549bfe9bb6b267e10bc557', |
|
166 | '38b5fe81f109cb111f549bfe9bb6b267e10bc557', | |
168 | 'fa6600f6848800641328adbf7811fd2372c02ab2', |
|
167 | 'fa6600f6848800641328adbf7811fd2372c02ab2', | |
169 | '102607b09cdd60e2793929c4f90478be29f85a17', |
|
168 | '102607b09cdd60e2793929c4f90478be29f85a17', | |
@@ -187,7 +186,7 b' class TestGitRepository:' | |||||
187 | 'f5ea29fc42ef67a2a5a7aecff10e1566699acd68', |
|
186 | 'f5ea29fc42ef67a2a5a7aecff10e1566699acd68', | |
188 | '27d48942240f5b91dfda77accd2caac94708cc7d', |
|
187 | '27d48942240f5b91dfda77accd2caac94708cc7d', | |
189 | '622f0eb0bafd619d2560c26f80f09e3b0b0d78af', |
|
188 | '622f0eb0bafd619d2560c26f80f09e3b0b0d78af', | |
190 |
'e686b958768ee96af8029fe19c6050b1a8dd3b2b' |
|
189 | 'e686b958768ee96af8029fe19c6050b1a8dd3b2b'} | |
191 | assert subset.issubset(set(self.repo.commit_ids)) |
|
190 | assert subset.issubset(set(self.repo.commit_ids)) | |
192 |
|
191 | |||
193 | def test_slicing(self): |
|
192 | def test_slicing(self): | |
@@ -281,12 +280,12 b' TODO: To be written...' | |||||
281 |
|
280 | |||
282 | new_branch = 'new_branch' |
|
281 | new_branch = 'new_branch' | |
283 | assert repo_clone._current_branch() == 'master' |
|
282 | assert repo_clone._current_branch() == 'master' | |
284 |
assert set(repo_clone.branches) == |
|
283 | assert set(repo_clone.branches) == {'master'} | |
285 | repo_clone._checkout(new_branch, create=True) |
|
284 | repo_clone._checkout(new_branch, create=True) | |
286 |
|
285 | |||
287 | # Branches is a lazy property so we need to recrete the Repo object. |
|
286 | # Branches is a lazy property so we need to recrete the Repo object. | |
288 | repo_clone = GitRepository(repo_clone.path) |
|
287 | repo_clone = GitRepository(repo_clone.path) | |
289 |
assert set(repo_clone.branches) == |
|
288 | assert set(repo_clone.branches) == {'master', new_branch} | |
290 | assert repo_clone._current_branch() == new_branch |
|
289 | assert repo_clone._current_branch() == new_branch | |
291 |
|
290 | |||
292 | def test_checkout(self): |
|
291 | def test_checkout(self): | |
@@ -1171,7 +1170,7 b' class TestGitRegression(BackendTestMixin' | |||||
1171 | assert paths == expected_paths |
|
1170 | assert paths == expected_paths | |
1172 |
|
1171 | |||
1173 |
|
1172 | |||
1174 | class TestDiscoverGitVersion: |
|
1173 | class TestDiscoverGitVersion(object): | |
1175 |
|
1174 | |||
1176 | def test_returns_git_version(self, baseapp): |
|
1175 | def test_returns_git_version(self, baseapp): | |
1177 | version = discover_git_version() |
|
1176 | version = discover_git_version() |
@@ -122,7 +122,7 b' class TestMercurialRepository:' | |||||
122 | repo = MercurialRepository(TEST_HG_REPO) |
|
122 | repo = MercurialRepository(TEST_HG_REPO) | |
123 | repo_clone = MercurialRepository( |
|
123 | repo_clone = MercurialRepository( | |
124 | TEST_HG_REPO_CLONE + '_w_update', |
|
124 | TEST_HG_REPO_CLONE + '_w_update', | |
125 |
src_url=TEST_HG_REPO, |
|
125 | src_url=TEST_HG_REPO, do_workspace_checkout=True) | |
126 | assert len(repo.commit_ids) == len(repo_clone.commit_ids) |
|
126 | assert len(repo.commit_ids) == len(repo_clone.commit_ids) | |
127 |
|
127 | |||
128 | # check if current workdir was updated |
|
128 | # check if current workdir was updated | |
@@ -133,7 +133,7 b' class TestMercurialRepository:' | |||||
133 | repo = MercurialRepository(TEST_HG_REPO) |
|
133 | repo = MercurialRepository(TEST_HG_REPO) | |
134 | repo_clone = MercurialRepository( |
|
134 | repo_clone = MercurialRepository( | |
135 | TEST_HG_REPO_CLONE + '_wo_update', |
|
135 | TEST_HG_REPO_CLONE + '_wo_update', | |
136 |
src_url=TEST_HG_REPO, |
|
136 | src_url=TEST_HG_REPO, do_workspace_checkout=False) | |
137 | assert len(repo.commit_ids) == len(repo_clone.commit_ids) |
|
137 | assert len(repo.commit_ids) == len(repo_clone.commit_ids) | |
138 | assert not os.path.isfile( |
|
138 | assert not os.path.isfile( | |
139 | os.path.join(TEST_HG_REPO_CLONE + '_wo_update', 'MANIFEST.in')) |
|
139 | os.path.join(TEST_HG_REPO_CLONE + '_wo_update', 'MANIFEST.in')) |
General Comments 0
You need to be logged in to leave comments.
Login now