def load_package_by_remote(self): """ 리모트 리파지토리에서 패키지를 로드 :return: """ # socore package clone from remote repository repository_url = self.__score_base + ':' + self.__score_package + '.git' # Repository Key 를 직접 등록 합니다. logging.debug("git Path :" + self.__package_path) # repo = Repo(str(self.__package_path)) git = Git(os.getcwd()) # check deploy key if os.path.exists(conf.DEFAULT_SCORE_REPOSITORY_KEY): st = os.stat(conf.DEFAULT_SCORE_REPOSITORY_KEY) # owner read only if bool(st.st_mode & stat.S_IRGRP or st.st_mode & stat.S_IROTH): os.chmod(conf.DEFAULT_SCORE_REPOSITORY_KEY, 0o600) ssh_cmd = 'ssh -o StrictHostKeyChecking=no -i ' + conf.DEFAULT_SCORE_REPOSITORY_KEY logging.debug("SSH KEY COMMAND : " + ssh_cmd) git.custom_environment(GIT_SSH_COMMAND=ssh_cmd) self.__package_repository = Repo._clone(git, repository_url, self.__package_path, GitCmdObjectDB, None) if conf.DEFAULT_SCORE_BRANCH != conf.DEFAULT_SCORE_BRANCH_MASTER: self.__package_repository.git.checkout(conf.DEFAULT_SCORE_BRANCH) return True
import os from git import * from git import Repo from git import Git git_ssh_identity_file = os.path.expanduser('~/.ssh/id_rsa') git_ssh_cmd = 'ssh -i %s' % git_ssh_identity_file git_url = 'ssh://[email protected]:7999/ter/td-test.git' repo_dir = 'temp1' with Git.custom_environment(GIT_SSH_COMMAND=git_ssh_cmd): #Repo.clone_from('[email protected]:7999', '/ter/td-test.git', branch='master') Repo.clone_from(git_url, repo_dir) print("Done")