Repository: ARMmbed/mbed-tools

Issue:
mbedtools clone <example> fails
### Description

<!--
A detailed description of what is being reported. Please include steps to reproduce the problem.

Things to consider sharing:
- What version of the package is being used (pip show mbed-tools)?
- What is the host platform and version (e.g. macOS 10.15.2, Windows 10, Ubuntu 18.04 LTS)?
-->
The clone command `mbedtools clone https://github.com/ARMmbed/mbed-os-example-blinky` fails with following error:
```
Cloning Mbed program 'https://github.com/ARMmbed/mbed-os-example-blinky'
Resolving program library dependencies.
ERROR: Cloning git repository from url 'https://github.com/ARMmbed/mbed-os/' failed. Error from VCS:

More information may be available by using the command line option '-v'.
```

### Issue request type

<!--
Please add only one `x` to one of the following types. Do not fill multiple types (split the issue otherwise).


For questions please use https://forums.mbed.com/
-->

- [ ] Enhancement
- [x] Bug


Discussion:
jainvikas8: Rebased on latest mater
codecov[bot]: # [Codecov](https://codecov.io/gh/ARMmbed/mbed-tools/pull/91?src=pr&el=h1) Report
> Merging [#91](https://codecov.io/gh/ARMmbed/mbed-tools/pull/91?src=pr&el=desc) into [master](https://codecov.io/gh/ARMmbed/mbed-tools/commit/a188be5d23cdc1f5c7434b439e9afed50a75e8ad?el=desc) will **increase** coverage by `0.99%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/ARMmbed/mbed-tools/pull/91/graphs/tree.svg?width=650&height=150&src=pr&token=QFRIdRv91G)](https://codecov.io/gh/ARMmbed/mbed-tools/pull/91?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master      #91      +/-   ##
==========================================
+ Coverage   95.44%   96.43%   +0.99%     
==========================================
  Files          92       92              
  Lines        2522     2524       +2     
==========================================
+ Hits         2407     2434      +27     
+ Misses        115       90      -25     
```


| [Impacted Files](https://codecov.io/gh/ARMmbed/mbed-tools/pull/91?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/mbed\_tools/project/\_internal/libraries.py](https://codecov.io/gh/ARMmbed/mbed-tools/pull/91/diff?src=pr&el=tree#diff-c3JjL21iZWRfdG9vbHMvcHJvamVjdC9faW50ZXJuYWwvbGlicmFyaWVzLnB5) | `98.11% <100.00%> (+0.07%)` | :arrow_up: |
| [...ools/devices/\_internal/detect\_candidate\_devices.py](https://codecov.io/gh/ARMmbed/mbed-tools/pull/91/diff?src=pr&el=tree#diff-c3JjL21iZWRfdG9vbHMvZGV2aWNlcy9faW50ZXJuYWwvZGV0ZWN0X2NhbmRpZGF0ZV9kZXZpY2VzLnB5) | `100.00% <0.00%> (+11.76%)` | :arrow_up: |
| [...d\_tools/devices/\_internal/linux/device\_detector.py](https://codecov.io/gh/ARMmbed/mbed-tools/pull/91/diff?src=pr&el=tree#diff-c3JjL21iZWRfdG9vbHMvZGV2aWNlcy9faW50ZXJuYWwvbGludXgvZGV2aWNlX2RldGVjdG9yLnB5) | `100.00% <0.00%> (+82.14%)` | :arrow_up: |


Patch:
diff --git a/news/66.bugfix b/news/66.bugfix
new file mode 100644
index 0000000..f920f1e
--- /dev/null
+++ b/news/66.bugfix
@@ -0,0 +1,1 @@
+Fix https to ssh redirection
diff --git a/src/mbed_tools/project/_internal/libraries.py b/src/mbed_tools/project/_internal/libraries.py
index cc417bf..abc4ccb 100644
--- a/src/mbed_tools/project/_internal/libraries.py
+++ b/src/mbed_tools/project/_internal/libraries.py
@@ -42,6 +42,10 @@ class MbedLibReference:
         """
         raw_ref = self.reference_file.read_text().strip()
         url, sep, ref = raw_ref.partition("#")
+
+        if url.endswith("/"):
+            url = url[:-1]
+
         return git_utils.GitReference(repo_url=url, ref=ref)
 
 


Test patch:
diff --git a/tests/project/_internal/test_project_data.py b/tests/project/_internal/test_project_data.py
index 51c0fad..6be1510 100644
--- a/tests/project/_internal/test_project_data.py
+++ b/tests/project/_internal/test_project_data.py
@@ -108,13 +108,15 @@ class TestMbedLibReference(TestCase):
         root = pathlib.Path(fs, "foo")
         url = "https://github.com/mylibrepo"
         ref = "latest"
-        full_ref = f"{url}#{ref}"
-        lib = make_mbed_lib_reference(root, ref_url=full_ref)
+        references = [f"{url}#{ref}", f"{url}/#{ref}"]
 
-        reference = lib.get_git_reference()
+        for full_ref in references:
+            lib = make_mbed_lib_reference(root, ref_url=full_ref)
 
-        self.assertEqual(reference.repo_url, url)
-        self.assertEqual(reference.ref, ref)
+            reference = lib.get_git_reference()
+
+            self.assertEqual(reference.repo_url, url)
+            self.assertEqual(reference.ref, ref)
 
 
 class TestMbedOS(TestCase):