@@ -653,10 +653,10 @@ def checkout(rev, clean=False):
653
653
popen ([git_cmd , 'checkout' , rev ] + (['-f' ] if clean else []) + ([] if very_verbose else ['-q' ]))
654
654
655
655
def update (rev = None , clean = False , clean_files = False , is_local = False ):
656
- if clean :
657
- Git .discard (clean_files )
658
656
if not is_local :
659
657
Git .fetch ()
658
+ if clean :
659
+ Git .discard (clean_files )
660
660
if rev :
661
661
Git .checkout (rev , clean )
662
662
else :
@@ -668,11 +668,11 @@ def update(rev=None, clean=False, clean_files=False, is_local=False):
668
668
except ProcessException :
669
669
pass
670
670
else :
671
- err = "Unable to update \" %s\" in \" %s\" .\n " % (os .path .basename (os .getcwd ()), os .getcwd ())
671
+ err = "Unable to update \" %s\" in \" %s\" ." % (os .path .basename (os .getcwd ()), os .getcwd ())
672
672
if not remote :
673
- info (err + "The local repository is not associated with a remote one." )
673
+ info (err + " The local repository is not associated with a remote one." )
674
674
if not branch :
675
- info (err + "Working set is not on a branch." )
675
+ info (err + " Working set is not on a branch." )
676
676
677
677
def status ():
678
678
return pquery ([git_cmd , 'status' , '-s' ] + (['-v' ] if very_verbose else []))
@@ -844,7 +844,7 @@ def fromurl(cls, url, path=None):
844
844
repo .path = os .path .abspath (path or os .path .join (os .getcwd (), repo .name ))
845
845
repo .url = formaturl (m_repo_url .group (1 ))
846
846
repo .rev = m_repo_url .group (3 )
847
- if repo .rev and not re .match (r'^([a-fA-F0-9]{6,40})$' , repo .rev ):
847
+ if repo .rev and repo . rev != 'latest' and not re .match (r'^([a-fA-F0-9]{6,40})$' , repo .rev ):
848
848
error ('Invalid revision (%s)' % repo .rev , - 1 )
849
849
else :
850
850
error ('Invalid repository (%s)' % url .strip (), - 1 )
@@ -1634,15 +1634,11 @@ def new(name, scm='git', program=False, library=False, mbedlib=False, create_onl
1634
1634
p .path = cwd_root
1635
1635
p .set_root ()
1636
1636
if not create_only and not p .get_os_dir () and not p .get_mbedlib_dir ():
1637
- url = mbed_lib_url if mbedlib else mbed_os_url
1637
+ url = mbed_lib_url if mbedlib else mbed_os_url + '#latest'
1638
1638
d = 'mbed' if mbedlib else 'mbed-os'
1639
1639
try :
1640
1640
with cd (d_path ):
1641
1641
add (url , depth = depth , protocol = protocol , top = False )
1642
- if not mbedlib :
1643
- with cd (d ):
1644
- repo = Repo .fromrepo ()
1645
- repo .checkout ('latest' )
1646
1642
except Exception as e :
1647
1643
if os .path .isdir (os .path .join (d_path , d )):
1648
1644
rmtree_readonly (os .path .join (d_path , d ))
@@ -1694,7 +1690,7 @@ def import_(url, path=None, ignore=False, depth=None, protocol=None, top=True):
1694
1690
with cd (repo .path ):
1695
1691
Program (repo .path ).set_root ()
1696
1692
try :
1697
- if repo .getrev () != repo .rev :
1693
+ if repo .rev and repo . getrev () != repo .rev :
1698
1694
repo .checkout (repo .rev , True )
1699
1695
except ProcessException as e :
1700
1696
err = "Unable to update \" %s\" to %s" % (repo .name , repo .revtype (repo .rev , True ))
0 commit comments