示例#1
0
def submodules_update(args, release_version, branch):
    print_stage("Updating Submodules")
    if make_utils.command_missing(args.git_command):
        sys.stderr.write("git not found, can't update code\n")
        sys.exit(1)

    # Update submodules to appropriate given branch,
    # falling back to master if none is given and/or found in a sub-repository.
    branch_fallback = "master"
    if not branch:
        branch = branch_fallback

    submodules = [
        ("release/scripts/addons", branch, branch_fallback),
        ("release/scripts/addons_contrib", branch, branch_fallback),
        ("release/datafiles/locale", branch, branch_fallback),
        ("source/tools", branch, branch_fallback),
    ]

    # Initialize submodules only if needed.
    for submodule_path, submodule_branch, submodule_branch_fallback in submodules:
        if not os.path.exists(os.path.join(submodule_path, ".git")):
            call([
                args.git_command, "submodule", "update", "--init",
                "--recursive"
            ])
            break

    # Checkout appropriate branch and pull changes.
    skip_msg = ""
    for submodule_path, submodule_branch, submodule_branch_fallback in submodules:
        cwd = os.getcwd()
        try:
            os.chdir(submodule_path)
            msg = git_update_skip(args, check_remote_exists=False)
            if msg:
                skip_msg += submodule_path + " skipped: " + msg + "\n"
            else:
                if make_utils.git_branch(args.git_command) != submodule_branch:
                    call([args.git_command, "fetch", "origin"])
                    call([args.git_command, "checkout", submodule_branch])
                call([
                    args.git_command, "pull", "--rebase", "origin",
                    submodule_branch
                ])
                # If we cannot find the specified branch for this submodule, fallback to default one (aka master).
                if make_utils.git_branch(args.git_command) != submodule_branch:
                    call([args.git_command, "fetch", "origin"])
                    call([
                        args.git_command, "checkout", submodule_branch_fallback
                    ])
                    call([
                        args.git_command, "pull", "--rebase", "origin",
                        submodule_branch_fallback
                    ])
        finally:
            os.chdir(cwd)

    return skip_msg
示例#2
0
def submodules_update(args, release_version, branch):
    print_stage("Updating Submodules")
    if make_utils.command_missing(args.git_command):
        sys.stderr.write("git not found, can't update code\n")
        sys.exit(1)

    # Update submodules to latest master or appropriate release branch.
    if not release_version:
        branch = "master"

    submodules = [
        ("release/scripts/addons", branch),
        ("release/scripts/addons_contrib", branch),
        ("release/datafiles/locale", branch),
        ("source/tools", branch),
    ]

    # Initialize submodules only if needed.
    for submodule_path, submodule_branch in submodules:
        if not os.path.exists(os.path.join(submodule_path, ".git")):
            call([
                args.git_command, "submodule", "update", "--init",
                "--recursive"
            ])
            break

    # Checkout appropriate branch and pull changes.
    skip_msg = ""
    for submodule_path, submodule_branch in submodules:
        cwd = os.getcwd()
        try:
            os.chdir(submodule_path)
            msg = git_update_skip(args, check_remote_exists=False)
            if msg:
                skip_msg += submodule_path + " skipped: " + msg + "\n"
            else:
                if make_utils.git_branch(args.git_command) != submodule_branch:
                    call([args.git_command, "fetch", "origin"])
                    call([args.git_command, "checkout", submodule_branch])
                call([
                    args.git_command, "pull", "--rebase", "origin",
                    submodule_branch
                ])
        finally:
            os.chdir(cwd)

    return skip_msg
示例#3
0
                    args.git_command, "pull", "--rebase", "origin",
                    submodule_branch
                ])
        finally:
            os.chdir(cwd)

    return skip_msg


if __name__ == "__main__":
    args = parse_arguments()
    blender_skip_msg = ""
    submodules_skip_msg = ""

    # Test if we are building a specific release version.
    branch = make_utils.git_branch(args.git_command)
    release_version = make_utils.git_branch_release_version(branch)

    if not args.no_libraries:
        svn_update(args, release_version)
    if not args.no_blender:
        blender_skip_msg = git_update_skip(args)
        if blender_skip_msg:
            blender_skip_msg = "Blender repository skipped: " + blender_skip_msg + "\n"
        else:
            blender_update(args)
    if not args.no_submodules:
        submodules_skip_msg = submodules_update(args, release_version, branch)

    # Report any skipped repositories at the end, so it's not as easy to miss.
    skip_msg = blender_skip_msg + submodules_skip_msg