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

IOTBTOOL-279: Fix default branch #896

Merged
merged 1 commit into from
Jun 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions mbed/mbed.py
Original file line number Diff line number Diff line change
Expand Up @@ -1278,12 +1278,23 @@ def clone(self, url, path, rev=None, depth=None, protocol=None, offline=False, *
with self.cache_lock_held(url):
shutil.copytree(cache, path)

#
# If no revision was specified, use the branch associated with the cache. In the
# github case this will be the default branch (IOTBTOOL-279)
#
if not rev:
with cd(cache):
branch = scm.getbranch()
if branch:
rev = branch
else:
# Can't find the cache branch; use a sensible default
rev = scm.default_branch

with cd(path):
scm.seturl(formaturl(url, protocol))
scm.cleanup()
info("Update cached copy from remote repository")
if not rev:
rev = scm.default_branch
scm.update(rev, True, is_local=offline)
main = False
except (ProcessException, IOError):
Expand Down