electron: update.py: add --force parameter
This commit is contained in:
@@ -17,7 +17,8 @@ to specify the major release to be updated.
|
|||||||
The `update-all command updates all non-eol major releases.
|
The `update-all command updates all non-eol major releases.
|
||||||
|
|
||||||
The `update` and `update-all` commands accept an optional `--commit`
|
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 base64
|
||||||
import json
|
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))
|
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
|
"""Update a given electron-source release
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
version: The major version number, e.g. '27'
|
version: The major version number, e.g. '27'
|
||||||
commit: Whether the updater should commit the result
|
commit: Whether the updater should commit the result
|
||||||
|
force: Whether to fetch even when the version is already up-to-date
|
||||||
"""
|
"""
|
||||||
major_version = version
|
major_version = version
|
||||||
|
|
||||||
@@ -198,7 +200,7 @@ def update_source(version: str, commit: bool) -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
m, rev = get_latest_version(major_version)
|
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")
|
print(f"{package_name} is up-to-date")
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -222,13 +224,15 @@ def cli() -> None:
|
|||||||
@cli.command("update", help="Update a single major release")
|
@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("-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")
|
@click.option("-c", "--commit", is_flag=True, default=False, help="Commit the result")
|
||||||
def update(version: str, commit: bool) -> None:
|
@click.option("-f", "--force", is_flag=True, default=False, help="Skip up-to-date version check")
|
||||||
update_source(version, commit)
|
def update(version: str, commit: bool, force: bool) -> None:
|
||||||
|
update_source(version, commit, force)
|
||||||
|
|
||||||
|
|
||||||
@cli.command("update-all", help="Update all releases at once")
|
@cli.command("update-all", help="Update all releases at once")
|
||||||
@click.option("-c", "--commit", is_flag=True, default=False, help="Commit the result")
|
@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
|
"""Update all eletron-source releases at once
|
||||||
|
|
||||||
Args:
|
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())))
|
filtered_releases = non_eol_releases(tuple(map(lambda x: int(x), old_info.keys())))
|
||||||
|
|
||||||
for major_version in filtered_releases:
|
for major_version in filtered_releases:
|
||||||
update_source(str(major_version), commit)
|
update_source(str(major_version), commit, force)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user