-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using buildchain repository info allow to check and modify versions.j…
…son file based on commit message for tool4D arm macOS
- Loading branch information
1 parent
10e7ecc
commit 5e47405
Showing
2 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,4 +32,4 @@ | |
"main": "293889" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import json | ||
import sys | ||
from pathlib import Path | ||
import git | ||
import re | ||
|
||
buildchain_dir="" | ||
if len(sys.argv)>1: | ||
buildchain_dir=sys.argv[1] | ||
|
||
if not buildchain_dir: | ||
buildchain_dir="../buildchain" # check in parent folder | ||
if(not Path(buildchain_dir).is_dir()): | ||
buildchain_dir="buildchain" # check inside | ||
|
||
if(not Path(buildchain_dir).is_dir()): | ||
print("🔴 buildChain directory not found", file=sys.stderr) | ||
exit(1) | ||
|
||
repo = git.Repo(buildchain_dir) | ||
|
||
filename = 'versions.json' | ||
with open(filename, 'r') as file: | ||
data = json.load(file) | ||
if not data: | ||
print("🔴 cannot read version file", file=sys.stderr) | ||
exit(2) | ||
|
||
from subprocess import PIPE | ||
|
||
official=data["official"] | ||
|
||
has_change = False | ||
|
||
for product_line in official: | ||
if (product_line == "20.x"): | ||
# print(f"skip product_line {product_line}") | ||
continue | ||
|
||
for version in official[product_line]: | ||
if (product_line == "20Rx") and int(version.replace("R", ""))<207: | ||
# print(f"skip version {version}") | ||
continue | ||
|
||
print(f"Manage product_line {product_line}, version {version}") | ||
|
||
res =repo.git.execute(f"git log --first-parent origin/{version} --pretty=format:%s -n1 -- mac/bin/tool4d_arm64.tar.xz", shell=True, istream=PIPE, with_stdout=True) | ||
matches = re.search(".*-(\d\d\d\d\d\d)-.*", res) | ||
if matches: | ||
match = matches.group(1) | ||
change_list=official[product_line][version] | ||
|
||
if isinstance(change_list, dict): | ||
alt_change_list = change_list["product_line"] | ||
alt_version = change_list["version"] | ||
change_list = change_list["build"] | ||
|
||
if change_list != match: | ||
print(f" ➡️ update from {change_list} {match}") | ||
if version in res: | ||
official[product_line][version] = match | ||
has_change = True | ||
else: | ||
if "main" in res: | ||
official[product_line][version] = {product_line: "main", version: "main", change_list: change_list} | ||
has_change = True | ||
else: | ||
print(f" 🔴 not managed other branch in commit message {res}") | ||
# TODO: must extract product_line | ||
else: | ||
print(f" ✅ up to date {change_list}") | ||
else: | ||
print(f" 🔴 not found in commit message {res}") | ||
print("") | ||
|
||
if has_change: | ||
with open(filename, "w") as outfile: | ||
json.dump(data, outfile, indent=2) |