From 822ba6348641d2530bc3c0963bc67f3c701a5e7a Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 2 Dec 2016 20:47:37 +0200 Subject: [PATCH] Fix unable to include SSH user in ``lib_deps`` repository url // Resolve #830 Resolve #836 --- HISTORY.rst | 2 + platformio/managers/package.py | 9 ++-- tests/test_managers.py | 94 +++++++++++++++++++++------------- 3 files changed, 65 insertions(+), 40 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 4cd9a10b..a87adbe0 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -40,6 +40,8 @@ PlatformIO 3.0 for circular dependencies * Show vendor version of a package for `platformio platform show `__ command (`issue #838 `_) +* Fixed unable to include SSH user in ``lib_deps`` repository url + (`issue #830 `_) * Fixed issue with ``PATH`` auto-configuring for upload tools * Fixed ``99-platformio-udev.rules`` checker for Linux OS diff --git a/platformio/managers/package.py b/platformio/managers/package.py index 6f10bc38..34802d79 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -170,7 +170,7 @@ class PkgInstallerMixin(object): break except Exception as e: # pylint: disable=broad-except 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: raise exception.UnknownPackage(name) @@ -297,12 +297,15 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): def parse_pkg_name( # pylint: disable=too-many-branches text, requirements=None): 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) if text.isdigit(): text = "id=" + text - url_marker = "://" name, url = (None, text) if "=" in text and not text.startswith("id="): name, url = text.split("=", 1) diff --git a/tests/test_managers.py b/tests/test_managers.py index f99038e6..14ee9e38 100644 --- a/tests/test_managers.py +++ b/tests/test_managers.py @@ -23,43 +23,63 @@ def test_pkg_name_parser(): ["PkgName@1.2.3", ("PkgName", "1.2.3", None)], [("PkgName@1.2.3", "1.2.5"), ("PkgName@1.2.3", "1.2.5", None)], ["id:13", ("id:13", None, None)], - ["id:13@~1.2.3", ("id:13", "~1.2.3", None)], - [util.get_home_dir(), - (".platformio", None, "file://" + util.get_home_dir())], - ["LocalName=" + util.get_home_dir(), - ("LocalName", None, "file://" + util.get_home_dir())], - ["https://github.com/user/package.git", - ("package", None, "git+https://github.com/user/package.git")], - ["https://gitlab.com/user/package.git", - ("package", None, "git+https://gitlab.com/user/package.git")], - ["https://github.com/user/package/archive/branch.zip", - ("branch", None, - "https://github.com/user/package/archive/branch.zip")], - ["https://github.com/user/package/archive/branch.tar.gz", - ("branch", None, - "https://github.com/user/package/archive/branch.tar.gz")], - ["https://developer.mbed.org/users/user/code/package/", - ("package", None, - "hg+https://developer.mbed.org/users/user/code/package/")], - ["https://github.com/user/package#v1.2.3", - ("package", None, "git+https://github.com/user/package#v1.2.3")], - ["https://github.com/user/package.git#branch", - ("package", None, "git+https://github.com/user/package.git#branch")], - ["PkgName=https://github.com/user/package.git#a13d344fg56", - ("PkgName", None, - "git+https://github.com/user/package.git#a13d344fg56")], - ["PkgName=user/package", - ("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")] + ["id:13@~1.2.3", ("id:13", "~1.2.3", None)], [ + util.get_home_dir(), + (".platformio", None, "file://" + util.get_home_dir()) + ], [ + "LocalName=" + util.get_home_dir(), + ("LocalName", None, "file://" + util.get_home_dir()) + ], [ + "https://github.com/user/package.git", + ("package", None, "git+https://github.com/user/package.git") + ], [ + "https://gitlab.com/user/package.git", + ("package", None, "git+https://gitlab.com/user/package.git") + ], [ + "https://github.com/user/package/archive/branch.zip", + ("branch", None, + "https://github.com/user/package/archive/branch.zip") + ], [ + "https://github.com/user/package/archive/branch.tar.gz", + ("branch", None, + "https://github.com/user/package/archive/branch.tar.gz") + ], [ + "https://developer.mbed.org/users/user/code/package/", + ("package", None, + "hg+https://developer.mbed.org/users/user/code/package/") + ], [ + "https://github.com/user/package#v1.2.3", + ("package", None, "git+https://github.com/user/package#v1.2.3") + ], [ + "https://github.com/user/package.git#branch", + ("package", None, "git+https://github.com/user/package.git#branch") + ], [ + "PkgName=https://github.com/user/package.git#a13d344fg56", + ("PkgName", None, + "git+https://github.com/user/package.git#a13d344fg56") + ], [ + "PkgName=user/package", + ("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: if isinstance(params, tuple):