Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-cli
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Operations
Operations
Metrics
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-cli
Commits
6b69e274
Commit
6b69e274
authored
Sep 24, 2021
by
Silvano Cerza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[skip changelog] Add unit test for lib install from git url (#1464)
parent
2a93ac9e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
78 additions
and
12 deletions
+78
-12
arduino/libraries/librariesmanager/install.go
arduino/libraries/librariesmanager/install.go
+4
-2
arduino/libraries/librariesmanager/install_test.go
arduino/libraries/librariesmanager/install_test.go
+64
-0
i18n/data/en.po
i18n/data/en.po
+3
-3
i18n/rice-box.go
i18n/rice-box.go
+7
-7
No files found.
arduino/libraries/librariesmanager/install.go
View file @
6b69e274
...
...
@@ -235,15 +235,17 @@ func (lm *LibrariesManager) InstallGitLib(gitURL string, overwrite bool) error {
return
nil
}
// parseGitURL tries to recover a library name from a git URL.
// Returns an error in case the URL is not a valid git URL.
func
parseGitURL
(
gitURL
string
)
(
string
,
error
)
{
var
res
string
if
strings
.
HasPrefix
(
gitURL
,
"git@"
)
{
// We can't parse these as URLs
i
:=
strings
.
LastIndex
(
gitURL
,
"/"
)
res
=
strings
.
TrimSuffix
(
gitURL
[
i
+
1
:
],
".git"
)
}
else
if
path
:=
paths
.
New
(
gitURL
);
path
.
Exist
()
{
}
else
if
path
:=
paths
.
New
(
gitURL
);
path
!=
nil
&&
path
.
Exist
()
{
res
=
path
.
Base
()
}
else
if
parsed
,
err
:=
url
.
Parse
(
gitURL
);
err
==
nil
{
}
else
if
parsed
,
err
:=
url
.
Parse
(
gitURL
);
parsed
.
String
()
!=
""
&&
err
==
nil
{
i
:=
strings
.
LastIndex
(
parsed
.
Path
,
"/"
)
res
=
strings
.
TrimSuffix
(
parsed
.
Path
[
i
+
1
:
],
".git"
)
}
else
{
...
...
arduino/libraries/librariesmanager/install_test.go
0 → 100644
View file @
6b69e274
// This file is part of arduino-cli.
//
// Copyright 2020 ARDUINO SA (http://www.arduino.cc/)
//
// This software is released under the GNU General Public License version 3,
// which covers the main part of arduino-cli.
// The terms of this license can be found at:
// https://www.gnu.org/licenses/gpl-3.0.en.html
//
// You can be released from the requirements of the above licenses by purchasing
// a commercial license. Buying such a license is mandatory if you want to
// modify or otherwise use the software for commercial activities involving the
// Arduino software without disclosing the source code of your own applications.
// To purchase a commercial license, send an email to license@arduino.cc.
package
librariesmanager
import
(
"testing"
"github.com/stretchr/testify/require"
)
func
TestParseGitURL
(
t
*
testing
.
T
)
{
gitURL
:=
""
libraryName
,
err
:=
parseGitURL
(
gitURL
)
require
.
Equal
(
t
,
""
,
libraryName
)
require
.
Errorf
(
t
,
err
,
"invalid git url"
)
gitURL
=
"https://github.com/arduino/arduino-lib.git"
libraryName
,
err
=
parseGitURL
(
gitURL
)
require
.
Equal
(
t
,
"arduino-lib"
,
libraryName
)
require
.
NoError
(
t
,
err
)
gitURL
=
"git@github.com:arduino/arduino-lib.git"
libraryName
,
err
=
parseGitURL
(
gitURL
)
require
.
Equal
(
t
,
"arduino-lib"
,
libraryName
)
require
.
NoError
(
t
,
err
)
gitURL
=
"file:///path/to/arduino-lib"
libraryName
,
err
=
parseGitURL
(
gitURL
)
require
.
Equal
(
t
,
"arduino-lib"
,
libraryName
)
require
.
NoError
(
t
,
err
)
gitURL
=
"file:///path/to/arduino-lib.git"
libraryName
,
err
=
parseGitURL
(
gitURL
)
require
.
Equal
(
t
,
"arduino-lib"
,
libraryName
)
require
.
NoError
(
t
,
err
)
gitURL
=
"/path/to/arduino-lib"
libraryName
,
err
=
parseGitURL
(
gitURL
)
require
.
Equal
(
t
,
"arduino-lib"
,
libraryName
)
require
.
NoError
(
t
,
err
)
gitURL
=
"/path/to/arduino-lib.git"
libraryName
,
err
=
parseGitURL
(
gitURL
)
require
.
Equal
(
t
,
"arduino-lib"
,
libraryName
)
require
.
NoError
(
t
,
err
)
gitURL
=
"file:///path/to/arduino-lib"
libraryName
,
err
=
parseGitURL
(
gitURL
)
require
.
Equal
(
t
,
"arduino-lib"
,
libraryName
)
require
.
NoError
(
t
,
err
)
}
i18n/data/en.po
View file @
6b69e274
...
...
@@ -2775,7 +2775,7 @@ msgstr "invalid empty library version: %s"
msgid "invalid empty option found"
msgstr "invalid empty option found"
#: arduino/libraries/librariesmanager/install.go:25
0
#: arduino/libraries/librariesmanager/install.go:25
2
msgid "invalid git url"
msgstr "invalid git url"
...
...
@@ -2848,11 +2848,11 @@ msgstr "library %s already installed"
msgid "library already installed"
msgstr "library already installed"
#: arduino/libraries/librariesmanager/install.go:2
69
#: arduino/libraries/librariesmanager/install.go:2
71
msgid "library is not valid: missing file \"library.properties\""
msgstr "library is not valid: missing file \"library.properties\""
#: arduino/libraries/librariesmanager/install.go:26
4
#: arduino/libraries/librariesmanager/install.go:26
6
msgid "library is not valid: missing header file \"%s\""
msgstr "library is not valid: missing header file \"%s\""
...
...
i18n/rice-box.go
View file @
6b69e274
This source diff could not be displayed because it is too large. You can
view the blob
instead.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment