Exemplo n.º 1
0
Arquivo: repo.py Projeto: lurch/moban
def git_clone(requires):
    from git import Repo

    if sys.platform != "win32":
        # Unfortunately for windows user, the following function
        # needs shell=True, which expose security risk. I would
        # rather not to trade it with its marginal benefit
        make_sure_git_is_available()

    moban_home = get_moban_home()
    mkdir_p(moban_home)

    for require in requires:
        repo_name = get_repo_name(require.git_url)
        local_repo_folder = os.path.join(moban_home, repo_name)
        if os.path.exists(local_repo_folder):
            reporter.report_git_pull(repo_name)
            repo = Repo(local_repo_folder)
            repo.git.pull()
            if require.reference:
                repo.git.checkout(require.reference)
            elif require.branch:
                repo.git.checkout(require.branch)
            if require.submodule:
                reporter.report_info_message("updating submodule")
                repo.git.submodule("update")
        else:
            reporter.report_git_clone(require.git_url)
            repo = Repo.clone_from(require.git_url, local_repo_folder,
                                   **require.clone_params())
            if require.submodule:
                reporter.report_info_message("checking out submodule")
                repo.git.submodule("update", "--init")
Exemplo n.º 2
0
 def _copy(self, src_path, dest):
     dest_folder = os.path.dirname(dest)
     if dest_folder:
         utils.mkdir_p(dest_folder)
     reporter.report_copying(src_path, dest)
     shutil.copy(src_path, dest)
     self._count = self._count + 1
Exemplo n.º 3
0
 def _copy(self, src_path, dest):
     dest_folder = os.path.dirname(dest)
     if dest_folder:
         utils.mkdir_p(dest_folder)
     reporter.report_copying(src_path, dest)
     try:
         shutil.copy(src_path, dest)
         self._count = self._count + 1
     except PermissionError:
         reporter.report_error_message("No permission to write %s" % dest)
Exemplo n.º 4
0
Arquivo: repo.py Projeto: ayan-b/moban
def git_clone(requires):
    from git import Repo

    moban_home = get_moban_home()
    mkdir_p(moban_home)

    for require in requires:
        repo_name = get_repo_name(require.git_url)
        local_repo_folder = os.path.join(moban_home, repo_name)
        if os.path.exists(local_repo_folder):
            reporter.report_git_pull(repo_name)
            repo = Repo(local_repo_folder)
            repo.git.pull()
            if require.submodule:
                reporter.report_info_message("updating submodule")
                repo.git.submodule("update")
        else:
            reporter.report_git_clone(require.git_url)
            repo = Repo.clone_from(
                require.git_url, local_repo_folder, **require.clone_params()
            )
            if require.submodule:
                reporter.report_info_message("checking out submodule")
                repo.git.submodule("update", "--init")
Exemplo n.º 5
0
def test_mkdir_p():
    test_path = "a/b/c/d"
    mkdir_p(test_path)
    assert os.path.exists(test_path)
    rmtree(test_path)