2020# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
2121# DEALINGS IN THE SOFTWARE. 
2222
23- import  argparse , os , subprocess , sys 
23+ import  argparse , os , subprocess , sys ,  re 
2424from  urllib .parse  import  urlparse 
2525
2626useTag  =  'cib-013'       # --clone and --checkout retrieve this tag 
@@ -167,7 +167,7 @@ def download(url, basename=None):
167167    # ('repos/fastcomp', 'tbfleming/cib-emscripten-fastcomp.git', 'kripken/emscripten-fastcomp.git', True, 'incoming', 'incoming'), 
168168    # ('repos/fastcomp/tools/clang', 'tbfleming/cib-emscripten-fastcomp-clang.git', 'kripken/emscripten-fastcomp-clang.git', True, 'incoming', 'incoming'), 
169169    ('repos/emscripten' , 'tbfleming/cib-emscripten.git' , 'kripken/emscripten.git' , True , 'incoming' , 'cib' ),
170-     ('repos/wabt' , 'WebAssembly/wabt.git' , 'WebAssembly/wabt.git' , False , 'master ' , 'master ' ),
170+     ('repos/wabt' , 'WebAssembly/wabt.git' , 'WebAssembly/wabt.git' , False , 'main ' , 'main ' ),
171171    ('repos/binaryen' , 'tbfleming/cib-binaryen.git' , 'WebAssembly/binaryen.git' , True , 'master' , 'cib' ),
172172    ('repos/zip.js' , 'gildas-lormeau/zip.js.git' , 'gildas-lormeau/zip.js.git' , False , '3e7920810f63d5057ef6028833243105521da369' , '3e7920810f63d5057ef6028833243105521da369' ),
173173    ('repos/eos' , 'tbfleming/cib-eos.git' , 'EOSIO/eos.git' , True , 'dawn-v3.0.0' , 'cib' ),
@@ -185,6 +185,9 @@ def format():
185185    run ('chmod a-x *.md .gitignore src/*.h src/*.cpp src/*.js src/*.html src/*.txt src/rtl/*' )
186186    run ('chmod a-x src/eos/.gitignore src/eos/package.json src/eos/src/*' )
187187
188+ def  is_commit_hash (commit_hash ):
189+     return  re .match (r'^[0-9a-f]{40}$' , commit_hash )
190+ 
188191def  clone ():
189192    for  (path , url , upstream , isPushable , upstreamBranch , branch ) in  repos :
190193        if  os .path .isdir (path ):
@@ -194,9 +197,12 @@ def clone():
194197        dir  =  os .path .dirname (path )
195198        base  =  os .path .basename (path )
196199        run ('mkdir -p '  +  dir )
197-         run ('cd '  +  dir  +  ' && git clone '  +  gitProtocol  +  url  +  ' '  +  base )
200+         if  is_commit_hash (branch ):
201+             run ('cd '  +  dir  +  ' && git clone '  +  gitProtocol  +  url  +  ' '  +  base )
202+             run ('cd '  +  path  +  ' git checkout '  +  branch )
203+         else :
204+             run ('cd '  +  dir  +  ' && git clone --branch '  +  branch  +  ' --depth 1 '  +  gitProtocol  +  url  +  ' '  +  base )
198205        run ('cd '  +  path  +  ' && git remote add upstream '  +  gitProtocol  +  upstream )
199-         run ('cd '  +  path  +  ' && git checkout '  +  branch )
200206
201207def  status ():
202208    for  (path , url , upstream , isPushable , upstreamBranch , branch ) in  repos :
0 commit comments