Unverified Commit fe19e3c3 authored by Janik's avatar Janik Committed by GitHub
Browse files

Merge pull request #247240 from dritter/jetbrains-autocommit-updates

parents 10893ad9 a56241ed
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -380,6 +380,11 @@ def main():

    write_result(result)

    # Commit the result
    commitMessage = "jetbrains.plugins: update"
    print("#### Committing changes... ####")
    run(['git', 'commit', f'-m{commitMessage}', '--', f'{PLUGINS_FILE}'], check=True)


if __name__ == '__main__':
    main()
+24 −0
Original line number Diff line number Diff line
@@ -12,6 +12,8 @@ from packaging import version
updates_url = "https://www.jetbrains.com/updates/updates.xml"
current_path = pathlib.Path(__file__).parent
versions_file_path = current_path.joinpath("versions.json").resolve()
fromVersions = {}
toVersions = {}

logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)

@@ -74,6 +76,8 @@ def update_product(name, product):
            download_url = product["url-template"].format(version=version_or_build_number, versionMajorMinor=version_number)
            product["url"] = download_url
            if "sha256" not in product or product.get("build_number") != new_build_number:
                fromVersions[name] = product["version"]
                toVersions[name] = new_version
                logging.info("Found a newer version %s with build number %s.", new_version, new_build_number)
                product["version"] = new_version
                product["build_number"] = new_build_number
@@ -101,6 +105,26 @@ with open(versions_file_path, "w") as versions_file:
    json.dump(versions, versions_file, indent=2)
    versions_file.write("\n")

if len(toVersions) == 0:
    # No Updates found
    sys.exit(0)

if len(toVersions) == 1:
    commitMessage = ""
else:
    lowestVersion = min(fromVersions.values())
    highestVersion = max(toVersions.values())
    commitMessage = f"jetbrains: {lowestVersion} -> {highestVersion}"
    commitMessage += "\n\n"

for name in toVersions.keys():
    commitMessage += f"jetbrains.{name}: {fromVersions[name]} -> {toVersions[name]}\n"

# Commit the result
logging.info("#### Committing changes... ####")
subprocess.run(['git', 'commit', f'-m{commitMessage}', '--', f'{versions_file_path}'], check=True)

logging.info("#### Updating plugins ####")
plugin_script = current_path.joinpath("plugins/update_plugins.py").resolve()
subprocess.call(plugin_script)