Skip to content

Commit b69ab5a

Browse files
committed
Added more git repo providers
1 parent 763145c commit b69ab5a

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

internal/arduino/libraries/librariesmanager/install.go

+11-4
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,17 @@ func parseGitArgURL(argURL string) (string, string, plumbing.Revision, error) {
257257
return path.Base(), argURL, "", nil
258258
}
259259

260-
// Handle github-specific address in the form "[email protected]:arduino-libraries/SigFox.git"
261-
if strings.HasPrefix(argURL, "[email protected]:") {
262-
// We can't parse these as URLs
263-
argURL = "https://github.com/" + strings.TrimPrefix(argURL, "[email protected]:")
260+
// Handle commercial git-specific address in the form "[email protected]:arduino-libraries/SigFox.git"
261+
prefixes := map[string]string{
262+
"[email protected]:": "https://github.com/",
263+
"[email protected]:": "https://gitlab.com/",
264+
"[email protected]:": "https://bitbucket.org/",
265+
}
266+
for prefix, replacement := range prefixes {
267+
if strings.HasPrefix(argURL, prefix) {
268+
// We can't parse these as URLs
269+
argURL = replacement + strings.TrimPrefix(argURL, prefix)
270+
}
264271
}
265272

266273
parsedURL, err := url.Parse(argURL)

internal/arduino/libraries/librariesmanager/install_test.go

+7
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ func TestParseGitURL(t *testing.T) {
4848
require.Equal(t, "https://github.com/arduino/arduino-lib.git", gitURL)
4949
require.EqualValues(t, "", ref)
5050
}
51+
{
52+
libraryName, gitURL, ref, err := parseGitArgURL("[email protected]:arduino/arduino-lib.git")
53+
require.NoError(t, err)
54+
require.Equal(t, "arduino-lib", libraryName)
55+
require.Equal(t, "https://bitbucket.org/arduino/arduino-lib.git", gitURL)
56+
require.EqualValues(t, "", ref)
57+
}
5158
{
5259
libraryName, gitURL, ref, err := parseGitArgURL("[email protected]:arduino/arduino-lib.git#0.1.2")
5360
require.NoError(t, err)

0 commit comments

Comments
 (0)