def _doClone(self, source, cloneSource, branch, repo, dbLog):
		args = ('git', 'ls-remote', cloneSource, branch)
		output = check_output(args, cwd=repo, stderr=DEVNULL)
		if len(output) == 0:
			syslog(LOG_WARNING, "No branch '%s' in '%s'" % (branch, source))
			return []

		# For Git versions <1.9 clone of a shallow repository will fail, so
		# check the git version and clone the whole repository if it is <1.9
		gitVersOut = check_output(('git', '--version'), stderr=DEVNULL).decode('utf-8')
		if gitVersOut[:12] == "git version ":
			gitVers = LooseVersion(gitVersOut[12:])
		else:
			gitVers = LooseVersion("0")
		if len(dbLog) == 0 or gitVers < LooseVersion("1.9"):
			depth = None
			args = ('git', 'clone', '-q', '-b', branch, cloneSource, repo)
		else:
			output = output.decode('utf-8')
			if output[:40] == dbLog[-1].hash:
				return []
			depth = 5
			args = ('git', 'clone', '-q', '--depth', str(depth), '-b', branch, cloneSource, repo)

		lastGitLogLen = 0
		while True:
			check_call(args, cwd=repo, stdout=DEVNULL, stderr=DEVNULL)
			try:
				return self._catchUp(repo, branch, dbLog, source, lastGitLogLen)
			except NewCommitsNotReachedError as e:
				try:
					lastGitLogLen = e.gitLogLen
					depth += 10
					args = ('git', 'fetch', '--depth', str(depth))
				except __HOLE__:
					return self._catchUp(repo, branch, [], source, lastGitLogLen)
dataset/ETHPy150Open seoester/Git-Deployment-Handler/gitdh/modules/external.py/External._doClone