|
125 | 125 | # mbed SDK tools needed for programs based on mbed SDK library
|
126 | 126 | mbed_sdk_tools_url = 'https://mbed.org/users/mbed_official/code/mbed-sdk-tools'
|
127 | 127 |
|
| 128 | +# a list of public SCM service (github/butbucket) which support http, https and ssh schemas |
| 129 | +public_repo_services = ['bitbucket.org', 'github.com', 'gitlab.com'] |
| 130 | + |
| 131 | + |
128 | 132 | # verbose logging
|
129 | 133 | verbose = False
|
130 | 134 | very_verbose = False
|
@@ -1249,6 +1253,13 @@ def write(self):
|
1249 | 1253 | #print self.name, 'unmodified'
|
1250 | 1254 | return
|
1251 | 1255 |
|
| 1256 | + if up.hostname in public_repo_services: |
| 1257 | + # Safely convert repo URL to https schema if this is a public SCM service (github/butbucket), supporting all schemas. |
| 1258 | + # This allows anonymous cloning of public repos without having to have ssh keys and associated accounts at github/bitbucket/etc. |
| 1259 | + # Without this anonymous users will get clone errors with ssh repository links even if the repository is public. |
| 1260 | + # See hhttps://help.github.com/articles/which-remote-url-should-i-use/ |
| 1261 | + url = formaturl(url, 'https') |
| 1262 | + |
1252 | 1263 | ref = url.rstrip('/') + '/' + (('' if self.is_build else '#') + self.rev if self.rev else '')
|
1253 | 1264 | action("Updating reference \"%s\" -> \"%s\"" % (relpath(cwd_root, self.path) if cwd_root != self.path else self.name, ref))
|
1254 | 1265 | with open(self.lib, 'wb') as f:
|
@@ -1720,7 +1731,7 @@ def formaturl(url, format="default"):
|
1720 | 1731 | else:
|
1721 | 1732 | m = re.match(regex_repo_url, url)
|
1722 | 1733 | if m and m. group( 1) == '': # no protocol specified, probably ssh string like "[email protected]:ARMmbed/mbed-os.git"
|
1723 |
| - url = 'ssh://%s%s%s/%s.git' % (m.group(2) or 'git@', m.group(6), m.group(7), m.group(8)) # convert to common ssh URL-like format |
| 1734 | + url = 'ssh://%s%s%s/%s.git' % (m.group(2) or 'git@', m.group(6), m.group(7) or '', m.group(8)) # convert to common ssh URL-like format |
1724 | 1735 | m = re.match(regex_repo_url, url)
|
1725 | 1736 |
|
1726 | 1737 | if m:
|
|
0 commit comments