Fix unable to include SSH user in `lib_deps` repository url // Resolve #830 Resolve #836

This commit is contained in:
Ivan Kravets
2016-12-02 20:47:37 +02:00
parent acf56b28a1
commit 822ba63486
3 changed files with 65 additions and 40 deletions

View File

@ -40,6 +40,8 @@ PlatformIO 3.0
for circular dependencies for circular dependencies
* Show vendor version of a package for `platformio platform show <http://docs.platformio.org/en/stable/userguide/platforms/cmd_show.html>`__ command * Show vendor version of a package for `platformio platform show <http://docs.platformio.org/en/stable/userguide/platforms/cmd_show.html>`__ command
(`issue #838 <https://github.com/platformio/platformio/issues/838>`_) (`issue #838 <https://github.com/platformio/platformio/issues/838>`_)
* Fixed unable to include SSH user in ``lib_deps`` repository url
(`issue #830 <https://github.com/platformio/platformio/issues/830>`_)
* Fixed issue with ``PATH`` auto-configuring for upload tools * Fixed issue with ``PATH`` auto-configuring for upload tools
* Fixed ``99-platformio-udev.rules`` checker for Linux OS * Fixed ``99-platformio-udev.rules`` checker for Linux OS

View File

@ -170,7 +170,7 @@ class PkgInstallerMixin(object):
break break
except Exception as e: # pylint: disable=broad-except except Exception as e: # pylint: disable=broad-except
click.secho("Warning! Package Mirror: %s" % e, fg="yellow") click.secho("Warning! Package Mirror: %s" % e, fg="yellow")
click.secho("Looking for the another mirror...", fg="yellow") click.secho("Looking for other mirror...", fg="yellow")
if versions is None: if versions is None:
raise exception.UnknownPackage(name) raise exception.UnknownPackage(name)
@ -297,12 +297,15 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin):
def parse_pkg_name( # pylint: disable=too-many-branches def parse_pkg_name( # pylint: disable=too-many-branches
text, requirements=None): text, requirements=None):
text = str(text) text = str(text)
if not requirements and "@" in text and not text.startswith("git@"): url_marker = "://"
if not any([
requirements, "@" not in text, text.startswith("git@"),
url_marker in text
]):
text, requirements = text.rsplit("@", 1) text, requirements = text.rsplit("@", 1)
if text.isdigit(): if text.isdigit():
text = "id=" + text text = "id=" + text
url_marker = "://"
name, url = (None, text) name, url = (None, text)
if "=" in text and not text.startswith("id="): if "=" in text and not text.startswith("id="):
name, url = text.split("=", 1) name, url = text.split("=", 1)

View File

@ -23,43 +23,63 @@ def test_pkg_name_parser():
["PkgName@1.2.3", ("PkgName", "1.2.3", None)], ["PkgName@1.2.3", ("PkgName", "1.2.3", None)],
[("PkgName@1.2.3", "1.2.5"), ("PkgName@1.2.3", "1.2.5", None)], [("PkgName@1.2.3", "1.2.5"), ("PkgName@1.2.3", "1.2.5", None)],
["id:13", ("id:13", None, None)], ["id:13", ("id:13", None, None)],
["id:13@~1.2.3", ("id:13", "~1.2.3", None)], ["id:13@~1.2.3", ("id:13", "~1.2.3", None)], [
[util.get_home_dir(), util.get_home_dir(),
(".platformio", None, "file://" + util.get_home_dir())], (".platformio", None, "file://" + util.get_home_dir())
["LocalName=" + util.get_home_dir(), ], [
("LocalName", None, "file://" + util.get_home_dir())], "LocalName=" + util.get_home_dir(),
["https://github.com/user/package.git", ("LocalName", None, "file://" + util.get_home_dir())
("package", None, "git+https://github.com/user/package.git")], ], [
["https://gitlab.com/user/package.git", "https://github.com/user/package.git",
("package", None, "git+https://gitlab.com/user/package.git")], ("package", None, "git+https://github.com/user/package.git")
["https://github.com/user/package/archive/branch.zip", ], [
("branch", None, "https://gitlab.com/user/package.git",
"https://github.com/user/package/archive/branch.zip")], ("package", None, "git+https://gitlab.com/user/package.git")
["https://github.com/user/package/archive/branch.tar.gz", ], [
("branch", None, "https://github.com/user/package/archive/branch.zip",
"https://github.com/user/package/archive/branch.tar.gz")], ("branch", None,
["https://developer.mbed.org/users/user/code/package/", "https://github.com/user/package/archive/branch.zip")
("package", None, ], [
"hg+https://developer.mbed.org/users/user/code/package/")], "https://github.com/user/package/archive/branch.tar.gz",
["https://github.com/user/package#v1.2.3", ("branch", None,
("package", None, "git+https://github.com/user/package#v1.2.3")], "https://github.com/user/package/archive/branch.tar.gz")
["https://github.com/user/package.git#branch", ], [
("package", None, "git+https://github.com/user/package.git#branch")], "https://developer.mbed.org/users/user/code/package/",
["PkgName=https://github.com/user/package.git#a13d344fg56", ("package", None,
("PkgName", None, "hg+https://developer.mbed.org/users/user/code/package/")
"git+https://github.com/user/package.git#a13d344fg56")], ], [
["PkgName=user/package", "https://github.com/user/package#v1.2.3",
("PkgName", None, "git+https://github.com/user/package")], ("package", None, "git+https://github.com/user/package#v1.2.3")
["PkgName=user/package#master", ], [
("PkgName", None, "git+https://github.com/user/package#master")], "https://github.com/user/package.git#branch",
["git+https://github.com/user/package", ("package", None, "git+https://github.com/user/package.git#branch")
("package", None, "git+https://github.com/user/package")], ], [
["hg+https://example.com/user/package", "PkgName=https://github.com/user/package.git#a13d344fg56",
("package", None, "hg+https://example.com/user/package")], ("PkgName", None,
["git@github.com:user/package.git", "git+https://github.com/user/package.git#a13d344fg56")
("package", None, "git@github.com:user/package.git")], ], [
["git@github.com:user/package.git#v1.2.0", "PkgName=user/package",
("package", None, "git@github.com:user/package.git#v1.2.0")] ("PkgName", None, "git+https://github.com/user/package")
], [
"PkgName=user/package#master",
("PkgName", None, "git+https://github.com/user/package#master")
], [
"git+https://github.com/user/package",
("package", None, "git+https://github.com/user/package")
], [
"hg+https://example.com/user/package",
("package", None, "hg+https://example.com/user/package")
], [
"git@github.com:user/package.git",
("package", None, "git@github.com:user/package.git")
], [
"git@github.com:user/package.git#v1.2.0",
("package", None, "git@github.com:user/package.git#v1.2.0")
], [
"git+ssh://git@gitlab.private-server.com/user/package#1.2.0",
("package", None,
"git+ssh://git@gitlab.private-server.com/user/package#1.2.0")
]
] ]
for params, result in items: for params, result in items:
if isinstance(params, tuple): if isinstance(params, tuple):