Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix an issue with arduino-cli lib install stripping too many characters from library names in git URLs #1462

Merged
merged 1 commit into from
Sep 23, 2021

Conversation

easyas314159
Copy link
Contributor

@easyas314159 easyas314159 commented Sep 22, 2021

Please check if the PR fulfills these requirements

  • The PR has no duplicates (please search among the Pull Requests
    before creating one)
  • The PR follows
    our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • UPGRADING.md has been updated with a migration guide (for breaking changes)
  • What kind of change does this PR introduce?

Fixes an issue with handling of git URLs when installing libraries using --git-url.

  • What is the current behavior?

When using arduino-cli lib install with the --git-url flag too many characters may be stripped from the end of the library name. Internally the librarymanagers parseGitURL function is incorrectly using strings.TrimRight instead of strings.TrimSuffix.

Example:

strings.TrimRight("NTPClient.git", ".git") => "NTPClien"
strings.TrimSuffix("NTPClient.git", ".git") => "NTPClient"
  • What is the new behavior?

parseGitURL now correctly strips the .git suffix from git URLs.

This PR contains no breaking changes

  • Other information:

There are not currently any test cases for arduino/libraries/librariesmanager/install.go, given the size of the change, and how much time I currently have available I'm not sure if unit tests for this are strictly necessary.


See how to contribute

TrimRight greedily removes as any matching characters from the cutset as possible which can inadvertently remove characters from the library name.
@CLAassistant
Copy link

CLAassistant commented Sep 22, 2021

CLA assistant check
All committers have signed the CLA.

@per1234
Copy link
Contributor

per1234 commented Sep 23, 2021

Thanks @easyas314159!

For the sake of linking things together, I'll add a note that this bug was reported by @FStefanni in the issue number #1459

@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels Sep 23, 2021
@silvanocerza
Copy link
Contributor

Thanks for the fix @easyas314159! Really appreciate it. 🙏

@silvanocerza silvanocerza merged commit 1db5944 into arduino:master Sep 23, 2021
silvanocerza pushed a commit that referenced this pull request Sep 24, 2021
TrimRight greedily removes as any matching characters from the cutset as possible which can inadvertently remove characters from the library name.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants