@@ -323,13 +323,18 @@ def import_(self, command):
323323
324324 # fetch updates for existing repo
325325 cmd_fetch = [GitClient ._executable , 'fetch' , remote ]
326- if command .shallow :
326+
327+ # Determine version type for both shallow and non-shallow modes
328+ version_type , version_name = None , None
329+ if checkout_version is not None :
327330 result_version_type , version_name = self ._check_version_type (
328331 command .url , checkout_version , command .retry
329332 )
330333 if result_version_type ['returncode' ]:
331334 return result_version_type
332335 version_type = result_version_type ['version_type' ]
336+
337+ if command .shallow :
333338 if version_type == 'branch' :
334339 cmd_fetch .append (
335340 'refs/heads/%s:refs/remotes/%s/%s'
@@ -345,7 +350,9 @@ def import_(self, command):
345350 assert False
346351 cmd_fetch += ['--depth' , '1' ]
347352 else :
348- version_type = None
353+ # For non-shallow mode, only fetch specific commit hashes
354+ if version_type == 'hash' :
355+ cmd_fetch .append (checkout_version )
349356 result_fetch = self ._run_command (cmd_fetch , retry = command .retry )
350357 if result_fetch ['returncode' ]:
351358 return result_fetch
@@ -422,6 +429,22 @@ def import_(self, command):
422429 return result_clone
423430 cmd = result_clone ['cmd' ]
424431 output = result_clone ['output' ]
432+
433+ # For non-shallow clones with commit hashes, fetch the specific commit
434+ if not command .shallow and version_type == 'hash' :
435+ cmd_fetch_hash = [
436+ GitClient ._executable ,
437+ 'fetch' ,
438+ 'origin' ,
439+ command .version ,
440+ ]
441+ result_fetch_hash = self ._run_command (
442+ cmd_fetch_hash , retry = command .retry
443+ )
444+ if result_fetch_hash ['returncode' ]:
445+ return result_fetch_hash
446+ cmd += ' && ' + ' ' .join (cmd_fetch_hash )
447+ output = '\n ' .join ([output , result_fetch_hash ['output' ]])
425448 else :
426449 # getting a hash or tag with a depth of 1 can't use 'clone'
427450 cmd_init = [GitClient ._executable , 'init' ]
0 commit comments