示例#1
0
文件: repo.py 项目: 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")
示例#2
0
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")
示例#3
0
def test_info_message():
    patcher = patch("sys.stdout", new_callable=StringIO)
    fake_stdout = patcher.start()
    reporter.report_info_message("for your information")
    patcher.stop()
    eq_(fake_stdout.getvalue(), "Info: for your information\n")