Skip to content

Commit de7ebdd

Browse files
IOTBTOOL-279: Fix default branch
Git now uses the branch that the cache was checked out to, rather than master, by default. This then follows the selection of 'default branch' as understood by github
1 parent 47aa820 commit de7ebdd

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

mbed/mbed.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,12 +1278,23 @@ def clone(self, url, path, rev=None, depth=None, protocol=None, offline=False, *
12781278
with self.cache_lock_held(url):
12791279
shutil.copytree(cache, path)
12801280

1281+
#
1282+
# If no revision was specified, use the branch associated with the cache. In the
1283+
# github case this will be the default branch (IOTBTOOL-279)
1284+
#
1285+
if not rev:
1286+
with cd(cache):
1287+
branch = scm.getbranch()
1288+
if branch:
1289+
rev = branch
1290+
else:
1291+
# Can't find the cache branch; use a sensible default
1292+
rev = scm.default_branch
1293+
12811294
with cd(path):
12821295
scm.seturl(formaturl(url, protocol))
12831296
scm.cleanup()
12841297
info("Update cached copy from remote repository")
1285-
if not rev:
1286-
rev = scm.default_branch
12871298
scm.update(rev, True, is_local=offline)
12881299
main = False
12891300
except (ProcessException, IOError):

0 commit comments

Comments
 (0)