forked from platformio/platformio-core
Handle url with ".git" extension as Git package/library
This commit is contained in:
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
VERSION = (3, 0, "0b9")
|
VERSION = (3, 0, "0b10")
|
||||||
__version__ = ".".join([str(s) for s in VERSION])
|
__version__ = ".".join([str(s) for s in VERSION])
|
||||||
|
|
||||||
__title__ = "platformio"
|
__title__ = "platformio"
|
||||||
|
@@ -324,13 +324,19 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin):
|
|||||||
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)
|
||||||
|
|
||||||
# Handle GitHub URL (https://github.com/user/package)
|
git_conditions = [
|
||||||
if url.startswith("https://github.com/") and \
|
# Handle GitHub URL (https://github.com/user/package)
|
||||||
not url.endswith((".zip", ".tar.gz")):
|
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
|
url = "git+" + url
|
||||||
# Handle Developer Mbed URL
|
# Handle Developer Mbed URL
|
||||||
# (https://developer.mbed.org/users/user/code/package/)
|
# (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
|
url = "hg+" + url
|
||||||
|
|
||||||
# git@github.com:user/package.git
|
# git@github.com:user/package.git
|
||||||
@@ -342,6 +348,8 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin):
|
|||||||
url = "file://" + url
|
url = "file://" + url
|
||||||
elif url.count("/") == 1 and not url.startswith("git@"):
|
elif url.count("/") == 1 and not url.startswith("git@"):
|
||||||
url = "git+https://github.com/" + url
|
url = "git+https://github.com/" + url
|
||||||
|
|
||||||
|
# determine name
|
||||||
if url_marker in url and not name:
|
if url_marker in url and not name:
|
||||||
_url = url.split("#", 1)[0] if "#" in url else url
|
_url = url.split("#", 1)[0] if "#" in url else url
|
||||||
if _url.endswith(("\\", "/")):
|
if _url.endswith(("\\", "/")):
|
||||||
|
@@ -52,6 +52,7 @@ def test_global_install_repository(clirunner, validate_cliresult,
|
|||||||
["-g",
|
["-g",
|
||||||
"install",
|
"install",
|
||||||
"https://github.com/gioblu/PJON.git#3.0",
|
"https://github.com/gioblu/PJON.git#3.0",
|
||||||
|
"https://gitlab.com/ivankravets/rs485-nodeproto.git",
|
||||||
# "https://developer.mbed.org/users/simon/code/TextLCD/",
|
# "https://developer.mbed.org/users/simon/code/TextLCD/",
|
||||||
"http://dl.platformio.org/libraries/archives/3/3756.tar.gz",
|
"http://dl.platformio.org/libraries/archives/3/3756.tar.gz",
|
||||||
"knolleary/pubsubclient"])
|
"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")])
|
for n in ("PJON", "git+https://github.com/knolleary/pubsubclient")])
|
||||||
items1 = [i['name'] for i in json.loads(result.output)]
|
items1 = [i['name'] for i in json.loads(result.output)]
|
||||||
items2 = ["OneWire", "DHT22", "PJON", "ESPAsyncTCP", "Json", "ArduinoJson",
|
items2 = ["OneWire", "DHT22", "PJON", "ESPAsyncTCP", "Json", "ArduinoJson",
|
||||||
"pubsubclient"]
|
"pubsubclient", "rs485-nodeproto"]
|
||||||
assert set(items1) == set(items2)
|
assert set(items1) == set(items2)
|
||||||
|
|
||||||
|
|
||||||
@@ -106,7 +107,7 @@ def test_global_lib_uninstall(clirunner, validate_cliresult,
|
|||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
items1 = [d.basename for d in isolated_pio_home.join("lib").listdir()]
|
items1 = [d.basename for d in isolated_pio_home.join("lib").listdir()]
|
||||||
items2 = ["DHT22_ID58", "Json_ID64", "ESPAsyncTCP_ID305", "pubsubclient",
|
items2 = ["DHT22_ID58", "Json_ID64", "ESPAsyncTCP_ID305", "pubsubclient",
|
||||||
"PJON"]
|
"PJON", "rs485-nodeproto"]
|
||||||
assert set(items1) == set(items2)
|
assert set(items1) == set(items2)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -30,6 +30,8 @@ def test_pkg_name_parser():
|
|||||||
("LocalName", None, "file://" + util.get_home_dir())],
|
("LocalName", None, "file://" + util.get_home_dir())],
|
||||||
["https://github.com/user/package.git",
|
["https://github.com/user/package.git",
|
||||||
("package", None, "git+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",
|
["https://github.com/user/package/archive/branch.zip",
|
||||||
("branch", None,
|
("branch", None,
|
||||||
"https://github.com/user/package/archive/branch.zip")],
|
"https://github.com/user/package/archive/branch.zip")],
|
||||||
|
Reference in New Issue
Block a user