Example #1
0
def run_pre_commit():
    """Run pre-commit."""
    try:
        command(["pre-commit", "run", "--all-files"])
    except subprocess.CalledProcessError:
        pass
    git_commit("Run pre-commit", allow_error=True)
Example #2
0
def update_icons(make_commit: bool = False):
    if url is not None:
        print(f"Downloading Material Design Icons from {url}")
        if download_file(url, "iconic-font.zip"):
            print("Archive downloaded")
        else:
            print("Error: Could not download archive", file=sys.stderr)
    else:
        print("URL is None. Do not download archive")
    if os.path.exists("iconic-font.zip"):
        unzip_archive("iconic-font.zip", temp_path)
        print("Unzip successful")
        os.remove("iconic-font.zip")
    if os.path.exists(temp_repo_path):
        shutil.copy2(temp_font_path, font_path)
        print("Font copied")
        icons, version = get_icons_list()
        print(f"Version {version}. {len(icons)} icons loaded")
        icon_definitions = make_icon_definitions(icons)
        export_icon_definitions(icon_definitions, version)
        print("File icon_definitions.py updated")
        shutil.rmtree(temp_path, ignore_errors=True)

        if make_commit:
            git_commit(
                f"Update Iconic font (v{version})",
                allow_error=True,
                add_files=[
                    "kivymd/icon_definitions.py",
                    "kivymd/fonts/materialdesignicons-webfont.ttf",
                ],
            )
            print("\nSuccessful. You can now push changes")
        else:
            print(
                f'\nSuccessful. Commit message: "Update Iconic font (v{version})"'
            )
    else:
        print(f"Error: {temp_repo_path} not exists", file=sys.stderr)
        exit(1)
Example #3
0
def main():
    parser = create_argument_parser()
    args = parser.parse_args()

    release = args.command == "release"
    version = args.version or "0.0.0"
    next_version = args.next_version or (
        (version[:-1] + str(int(version[-1]) + 1) + ".dev0")
        if "rc" not in version
        else version
    )
    prepare = args.command == "prepare"
    test = args.command == "test"
    ask = args.yes is not True
    push = args.push is True

    if release and version == "0.0.0":
        parser.error("Please specify new version.")
    version_re = r"[\d]{1,3}\.[\d]{1,3}\.[\d]{1,3}(rc[\d]{1,3})?"
    if not re.match(version_re, version):
        parser.error(f'Version "{version}" doesn\'t match template.')
    next_version_re = (
        r"[\d]{1,3}\.[\d]{1,3}\.[\d]{1,3}(\.dev[\d]{1,3}|rc[\d]{1,3})?"
    )
    if not re.match(next_version_re, next_version):
        parser.error(f'Next version "{next_version}" doesn\'t match template.')
    if test and push:
        parser.error("Don't use --push with test.")

    repository_root = os.path.normpath(
        os.path.dirname(
            os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
        )
    )

    # Change directory to repository root
    os.chdir(repository_root)

    previous_version = get_previous_version()

    # Print info
    print(f"Previous version: {previous_version}")
    print(f"New version: {version}")
    print(f"Next version: {next_version}")

    update_icons(make_commit=True)
    git_clean(ask=ask)
    run_pre_commit()

    if prepare:
        git_push([], ask=ask, push=push)
        return

    update_init_py(version, is_release=True, test=test)
    update_readme(previous_version, version, test=test)

    changelog_index_file = os.path.join(
        repository_root, "docs", "sources", "changelog", "index.rst"
    )
    changelog_unreleased_file = os.path.join(
        repository_root, "docs", "sources", "changelog", "unreleased.rst"
    )
    changelog_version_file = os.path.join(
        repository_root, "docs", "sources", "changelog", f"{version}.rst"
    )
    move_changelog(
        changelog_index_file,
        changelog_unreleased_file,
        previous_version,
        changelog_version_file,
        version,
        test=test,
    )

    git_commit(f"KivyMD {version}")
    git_tag(version)

    branches_to_push = []
    # Move branch stable to stable-x.x.x
    # command(["git", "branch", "-m", "stable", f"stable-{old_version}"])
    # branches_to_push.append(f"stable-{old_version}")
    # Create branch stable
    # command(["git", "branch", "stable"])
    # command(["git", "push", "--force", "origin", "master:stable"])
    # branches_to_push.append("stable")

    create_unreleased_changelog(
        changelog_index_file, changelog_unreleased_file, version, test=test,
    )
    update_init_py(next_version, is_release=False, test=test)
    git_commit(f"KivyMD {next_version}")
    git_push(branches_to_push, ask=ask, push=push)