@@ -608,7 +608,20 @@ def cleanup():
608
608
pquery ([git_cmd , 'branch' , '-D' , branch ])
609
609
610
610
def clone (url , name = None , depth = None , protocol = None ):
611
- popen ([git_cmd , 'clone' , formaturl (url , protocol ), name ] + (['--depth' , depth ] if depth else []) + (['-v' ] if very_verbose else ([] if verbose else ['-q' ])))
611
+ if depth :
612
+ repo_name = url .split ('/' )[- 1 ]
613
+ if '.git' in repo_name :
614
+ repo_name = repo_name [:- 4 ]
615
+
616
+ os .mkdir (repo_name )
617
+
618
+ with cd (repo_name ):
619
+ Git .init ()
620
+ Git .fetch (url = url , branch = 'latest' , depth = depth )
621
+ Git .checkout ('FETCH_HEAD' )
622
+ popen ([git_cmd , 'remote' , 'add' , 'origin' , url ])
623
+ else :
624
+ popen ([git_cmd , 'clone' , formaturl (url , protocol ), name ] + (['-v' ] if very_verbose else ([] if verbose else ['-q' ])))
612
625
613
626
def add (dest ):
614
627
info ("Adding reference " + dest )
@@ -642,9 +655,9 @@ def publish(all_refs=None):
642
655
if not branch :
643
656
error (err + "Working set is not on a branch." , 1 )
644
657
645
- def fetch ():
658
+ def fetch (url = None , branch = None , depth = None ):
646
659
info ("Fetching revisions from remote repository to \" %s\" " % os .path .basename (os .getcwd ()))
647
- popen ([git_cmd , 'fetch' , '--all' , '--tags' ] + (['-v' ] if very_verbose else ([] if verbose else ['-q' ])))
660
+ popen ([git_cmd , 'fetch' , '--tags' ] + ([ url ] if url else []) + ([ branch ] if branch else [ '-- all']) + ([ '--depth' , depth ] if depth else []) + (['-v' ] if very_verbose else ([] if verbose else ['-q' ])))
648
661
649
662
def discard (clean_files = False ):
650
663
info ("Discarding local changes in \" %s\" " % os .path .basename (os .getcwd ()))
@@ -1724,11 +1737,13 @@ def new(name, scm='git', program=False, library=False, mbedlib=False, create_onl
1724
1737
p .path = cwd_root
1725
1738
p .set_root ()
1726
1739
if not create_only and not p .get_os_dir () and not p .get_mbedlib_dir ():
1727
- url = mbed_lib_url if mbedlib else mbed_os_url + '#latest'
1740
+ url = mbed_lib_url if mbedlib else mbed_os_url + "#latest"
1741
+ print (url )
1728
1742
d = 'mbed' if mbedlib else 'mbed-os'
1729
1743
try :
1730
1744
with cd (d_path ):
1731
1745
add (url , depth = depth , protocol = protocol , top = False )
1746
+
1732
1747
except Exception as e :
1733
1748
if os .path .isdir (os .path .join (d_path , d )):
1734
1749
rmtree_readonly (os .path .join (d_path , d ))
@@ -1784,7 +1799,7 @@ def import_(url, path=None, ignore=False, depth=None, protocol=None, top=True):
1784
1799
with cd (repo .path ):
1785
1800
Program (repo .path ).set_root ()
1786
1801
try :
1787
- if repo .rev and repo .getrev () != repo .rev :
1802
+ if repo .rev and repo .getrev () != repo .rev and not depth :
1788
1803
repo .checkout (repo .rev , True )
1789
1804
except ProcessException as e :
1790
1805
err = "Unable to update \" %s\" to %s" % (repo .name , repo .revtype (repo .rev , True ))
@@ -1800,17 +1815,19 @@ def import_(url, path=None, ignore=False, depth=None, protocol=None, top=True):
1800
1815
warning (err )
1801
1816
else :
1802
1817
error (err , 1 )
1803
-
1804
- repo .sync ()
1818
+
1819
+ action ("Syncing repo." );
1820
+ #repo.sync()
1805
1821
1806
1822
if top : # This helps sub-commands to display relative paths to the imported program
1807
1823
cwd_root = repo .path
1808
1824
1809
- with cd (repo .path ):
1810
- deploy (ignore = ignore , depth = depth , protocol = protocol , top = False )
1825
+ # with cd(repo.path):
1826
+ # deploy(ignore=ignore, depth=depth, protocol=protocol, top=False)
1811
1827
1812
1828
if top :
1813
- Program (repo .path ).post_action ()
1829
+ action ("Post action." );
1830
+ #Program(repo.path).post_action()
1814
1831
1815
1832
1816
1833
# Add library command
@@ -1836,8 +1853,8 @@ def add(url, path=None, ignore=False, depth=None, protocol=None, top=True):
1836
1853
lib .write ()
1837
1854
repo .add (lib .lib )
1838
1855
1839
- if top :
1840
- Program (repo .path ).post_action ()
1856
+ # if top:
1857
+ # Program(repo.path).post_action()
1841
1858
1842
1859
1843
1860
# Remove library
0 commit comments