Unverified Commit a453bfc7 authored by Yureka's avatar Yureka Committed by GitHub
Browse files

electron: update.py: add --force parameter (#457315)

parents 0bd53b62 26d4980f
Loading
Loading
Loading
Loading
+11 −7
Original line number Diff line number Diff line
@@ -17,7 +17,8 @@ to specify the major release to be updated.
The `update-all command updates all non-eol major releases.

The `update` and `update-all` commands accept an optional `--commit`
flag to automatically commit the changes for you.
flag to automatically commit the changes for you, and `--force` to
skip the up-to-date version check.
"""
import base64
import json
@@ -178,12 +179,13 @@ def non_eol_releases(releases: Iterable[int]) -> Iterable[int]:
    return tuple(filter(lambda x: x in supported_version_range(), releases))


def update_source(version: str, commit: bool) -> None:
def update_source(version: str, commit: bool, force: bool) -> None:
    """Update a given electron-source release

    Args:
        version: The major version number, e.g. '27'
        commit: Whether the updater should commit the result
        force: Whether to fetch even when the version is already up-to-date
    """
    major_version = version

@@ -198,7 +200,7 @@ def update_source(version: str, commit: bool) -> None:
    )

    m, rev = get_latest_version(major_version)
    if old_version == m["version"]:
    if old_version == m["version"] and not force:
        print(f"{package_name} is up-to-date")
        return

@@ -222,13 +224,15 @@ def cli() -> None:
@cli.command("update", help="Update a single major release")
@click.option("-v", "--version", required=True, type=str, help="The major version, e.g. '23'")
@click.option("-c", "--commit", is_flag=True, default=False, help="Commit the result")
def update(version: str, commit: bool) -> None:
    update_source(version, commit)
@click.option("-f", "--force", is_flag=True, default=False, help="Skip up-to-date version check")
def update(version: str, commit: bool, force: bool) -> None:
    update_source(version, commit, force)


@cli.command("update-all", help="Update all releases at once")
@click.option("-c", "--commit", is_flag=True, default=False, help="Commit the result")
def update_all(commit: bool) -> None:
@click.option("-f", "--force", is_flag=True, default=False, help="Skip up-to-date version check")
def update_all(commit: bool, force: bool) -> None:
    """Update all eletron-source releases at once

    Args:
@@ -239,7 +243,7 @@ def update_all(commit: bool) -> None:
    filtered_releases = non_eol_releases(tuple(map(lambda x: int(x), old_info.keys())))

    for major_version in filtered_releases:
        update_source(str(major_version), commit)
        update_source(str(major_version), commit, force)


if __name__ == "__main__":