Handle url with ".git" extension as Git package/library

This commit is contained in:
Ivan Kravets
2016-09-03 01:27:34 +03:00
parent d4ffc89c02
commit e2d2295866
4 changed files with 18 additions and 7 deletions

View File

@ -14,7 +14,7 @@
import sys
VERSION = (3, 0, "0b9")
VERSION = (3, 0, "0b10")
__version__ = ".".join([str(s) for s in VERSION])
__title__ = "platformio"

View File

@ -324,13 +324,19 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin):
if "=" in text and not text.startswith("id="):
name, url = text.split("=", 1)
# Handle GitHub URL (https://github.com/user/package)
if url.startswith("https://github.com/") and \
not url.endswith((".zip", ".tar.gz")):
git_conditions = [
# Handle GitHub URL (https://github.com/user/package)
url.startswith("https://github.com/") and not url.endswith(
(".zip", ".tar.gz")),
url.startswith("http") and
(url.split("#", 1)[0] if "#" in url else url).endswith(".git")
]
if any(git_conditions):
url = "git+" + url
# Handle Developer Mbed URL
# (https://developer.mbed.org/users/user/code/package/)
if url.startswith("https://developer.mbed.org"):
elif url.startswith("https://developer.mbed.org"):
url = "hg+" + url
# git@github.com:user/package.git
@ -342,6 +348,8 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin):
url = "file://" + url
elif url.count("/") == 1 and not url.startswith("git@"):
url = "git+https://github.com/" + url
# determine name
if url_marker in url and not name:
_url = url.split("#", 1)[0] if "#" in url else url
if _url.endswith(("\\", "/")):

View File

@ -52,6 +52,7 @@ def test_global_install_repository(clirunner, validate_cliresult,
["-g",
"install",
"https://github.com/gioblu/PJON.git#3.0",
"https://gitlab.com/ivankravets/rs485-nodeproto.git",
# "https://developer.mbed.org/users/simon/code/TextLCD/",
"http://dl.platformio.org/libraries/archives/3/3756.tar.gz",
"knolleary/pubsubclient"])
@ -72,7 +73,7 @@ def test_global_lib_list(clirunner, validate_cliresult, isolated_pio_home):
for n in ("PJON", "git+https://github.com/knolleary/pubsubclient")])
items1 = [i['name'] for i in json.loads(result.output)]
items2 = ["OneWire", "DHT22", "PJON", "ESPAsyncTCP", "Json", "ArduinoJson",
"pubsubclient"]
"pubsubclient", "rs485-nodeproto"]
assert set(items1) == set(items2)
@ -106,7 +107,7 @@ def test_global_lib_uninstall(clirunner, validate_cliresult,
validate_cliresult(result)
items1 = [d.basename for d in isolated_pio_home.join("lib").listdir()]
items2 = ["DHT22_ID58", "Json_ID64", "ESPAsyncTCP_ID305", "pubsubclient",
"PJON"]
"PJON", "rs485-nodeproto"]
assert set(items1) == set(items2)

View File

@ -30,6 +30,8 @@ def test_pkg_name_parser():
("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")],