Exemplo n.º 1
0
 def update_editable(self):
     # type: () -> None
     if not self.link:
         logger.debug(
             "Cannot update repository at %s; repository location is "
             "unknown",
             self.source_dir,
         )
         return
     assert self.editable
     assert self.source_dir
     if self.link.scheme == 'file':
         # Static paths don't get updated
         return
     vcs_backend = vcs.get_backend_for_scheme(self.link.scheme)
     # Editable requirements are validated in Requirement constructors.
     # So here, if it's neither a path nor a valid VCS URL, it's a bug.
     assert vcs_backend, f"Unsupported VCS URL {self.link.url}"
     hidden_url = hide_url(self.link.url)
     vcs_backend.obtain(self.source_dir, url=hidden_url)
Exemplo n.º 2
0
 def update_editable(self, obtain=True):
     # type: (bool) -> None
     if not self.link:
         logger.debug(
             "Cannot update repository at %s; repository location is "
             "unknown",
             self.source_dir,
         )
         return
     assert self.editable
     assert self.source_dir
     if self.link.scheme == 'file':
         # Static paths don't get updated
         return
     assert '+' in self.link.url, "bad url: %r" % self.link.url
     vc_type, url = self.link.url.split('+', 1)
     vcs_backend = vcs.get_backend(vc_type)
     if vcs_backend:
         if not self.link.is_vcs:
             reason = (
                 "This form of VCS requirement is being deprecated: {}."
             ).format(
                 self.link.url
             )
             replacement = None
             if self.link.url.startswith("git+git@"):
                 replacement = (
                     "git+https://[email protected]/..., "
                     "git+ssh://[email protected]/..., "
                     "or the insecure git+git://[email protected]/..."
                 )
             deprecated(reason, replacement, gone_in="21.0", issue=7554)
         hidden_url = hide_url(self.link.url)
         if obtain:
             vcs_backend.obtain(self.source_dir, url=hidden_url)
         else:
             vcs_backend.export(self.source_dir, url=hidden_url)
     else:
         assert 0, (
             'Unexpected version control type (in {}): {}'.format(
                 self.link, vc_type))
Exemplo n.º 3
0
def test_export_rev(script, tmpdir):
    """Test that a Bazaar branch can be exported, specifying a rev."""
    source_dir = tmpdir / 'test-source'
    source_dir.mkdir()

    # Create a single file that is changed by two revisions.
    create_file(source_dir / 'test_file', 'something initial')
    _vcs_add(script, str(source_dir), vcs='bazaar')

    create_file(source_dir / 'test_file', 'something new')
    script.run(
        'bzr', 'commit', '-q',
        '--author', 'pip <*****@*****.**>',
        '-m', 'change test file', cwd=source_dir,
    )

    export_dir = tmpdir / 'export'
    url = hide_url('bzr+' + _test_path_to_file_url(source_dir) + '@1')
    Bazaar().export(str(export_dir), url=url)

    with open(export_dir / 'test_file', 'r') as f:
        assert f.read() == 'something initial'
Exemplo n.º 4
0
def unpack_vcs_link(link, location):
    # type: (Link, str) -> None
    vcs_backend = vcs.get_backend_for_scheme(link.scheme)
    assert vcs_backend is not None
    vcs_backend.unpack(location, url=hide_url(link.url))
Exemplo n.º 5
0
def unpack_vcs_link(link, location):
    # type: (Link, str) -> None
    vcs_backend = _get_used_vcs_backend(link)
    assert vcs_backend is not None
    vcs_backend.unpack(location, url=hide_url(link.url))
Exemplo n.º 6
0
def test_hide_url():
    hidden_url = hide_url('https://*****:*****@example.com')
    assert repr(hidden_url) == "<HiddenText 'https://*****:*****@example.com'>"
    assert str(hidden_url) == 'https://*****:*****@example.com'
    assert hidden_url.redacted == 'https://*****:*****@example.com'
    assert hidden_url.secret == 'https://*****:*****@example.com'
Exemplo n.º 7
0
 def test_update(self):
     self.svn.update(self.dest, hide_url(self.url), self.rev_options)
     self.assert_call_args([
         'svn', 'update', '--non-interactive', '/tmp/test',
     ])
Exemplo n.º 8
0
def unpack_vcs_link(link: Link, location: str, verbosity: int) -> None:
    vcs_backend = vcs.get_backend_for_scheme(link.scheme)
    assert vcs_backend is not None
    vcs_backend.unpack(location, url=hide_url(link.url), verbosity=verbosity)