Skip to content

Commit 89ca9f3

Browse files
committed
Better git url handling
1 parent 4a657f4 commit 89ca9f3

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

Diff for: arduino/libraries/librariesmanager/install.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func (lm *LibrariesManager) InstallGitLib(gitURL string) error {
137137

138138
func parseGitURL(gitURL string) (string, error) {
139139
var res string
140-
if strings.HasPrefix(gitURL, "git") || strings.HasPrefix(gitURL, "ssh") {
140+
if strings.HasPrefix(gitURL, "git@") {
141141
// We can't parse these as URLs
142142
i := strings.LastIndex(gitURL, "/")
143143
res = strings.TrimRight(gitURL[i+1:], ".git")

Diff for: test/test_lib.py

+22-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def test_install_git_url_and_zip_path_flags_visibility(run_command, data_dir, do
215215
assert "--git-url and --zip-path flags allow installing untrusted files, use it at your own risk." in res.stdout
216216

217217

218-
def test_install_with_git_url(run_command, data_dir, downloads_dir):
218+
def test_install_with_git_url_https(run_command, data_dir, downloads_dir):
219219
# Initialize configs to enable --git-url flag
220220
env = {
221221
"ARDUINO_DATA_DIR": data_dir,
@@ -236,6 +236,27 @@ def test_install_with_git_url(run_command, data_dir, downloads_dir):
236236
assert "Error installing Git Library: repository already exists" in res.stderr
237237

238238

239+
def test_install_with_git_url_ssh(run_command, data_dir, downloads_dir):
240+
# Initialize configs to enable --git-url flag
241+
env = {
242+
"ARDUINO_DATA_DIR": data_dir,
243+
"ARDUINO_DOWNLOADS_DIR": downloads_dir,
244+
"ARDUINO_SKETCHBOOK_DIR": data_dir,
245+
"ARDUINO_ENABLE_UNSAFE_LIBRARY_INSTALL": "true",
246+
}
247+
assert run_command("config init --dest-dir .", custom_env=env)
248+
249+
# Test git-url library install
250+
res = run_command("lib install --git-url [email protected]:arduino-libraries/WiFi101.git")
251+
assert res.ok
252+
assert "--git-url and --zip-path flags allow installing untrusted files, use it at your own risk." in res.stdout
253+
254+
# Test failing-install as repository already exists
255+
res = run_command("lib install --git-url [email protected]:arduino-libraries/WiFi101.git")
256+
assert "--git-url and --zip-path flags allow installing untrusted files, use it at your own risk." in res.stdout
257+
assert "Error installing Git Library: repository already exists" in res.stderr
258+
259+
239260
def test_install_with_zip_path(run_command, data_dir, downloads_dir):
240261
# Initialize configs to enable --zip-path flag
241262
env = {

0 commit comments

Comments
 (0)