From 3ee494686859ff54de39d9b9732ea8661182a8aa Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Sat, 2 Mar 2024 00:05:17 +0000 Subject: [PATCH 2/5] proto_ver_generator: use changelog, not git --- scripts/fbt_tools/fbt_assets.py | 42 ++++++++------------------------- 1 file changed, 10 insertions(+), 32 deletions(-) diff --git a/scripts/fbt_tools/fbt_assets.py b/scripts/fbt_tools/fbt_assets.py index 492a66b66..e6e31beae 100644 --- a/scripts/fbt_tools/fbt_assets.py +++ b/scripts/fbt_tools/fbt_assets.py @@ -78,39 +78,17 @@ def __invoke_git(args, source_dir): def _proto_ver_generator(target, source, env): + changelog_content = source[0].get_text_contents() + for ln in changelog_content.split('\n'): + ln = ln.strip() + if ln.startswith('## ['): + version = ln[len('## ['):-1] + break + else: + print("couldn't parse version from changelog " + str(source[0])) + Exit() target_file = target[0] - src_dir = source[0].dir.abspath - - def fetch(unshallow=False): - git_args = ["fetch", "--tags"] - if unshallow: - git_args.append("--unshallow") - - try: - __invoke_git(git_args, source_dir=src_dir) - except (subprocess.CalledProcessError, EnvironmentError): - # Not great, not terrible - print(fg.boldred("Git: fetch failed")) - - def describe(): - try: - return __invoke_git( - ["describe", "--tags", "--abbrev=0"], - source_dir=src_dir, - ) - except (subprocess.CalledProcessError, EnvironmentError): - return None - - fetch() - git_describe = describe() - if not git_describe: - fetch(unshallow=True) - git_describe = describe() - - if not git_describe: - raise StopError("Failed to process git tags for protobuf versioning") - - git_major, git_minor = git_describe.split(".") + git_major, git_minor = version.split(".") version_file_data = ( "#pragma once", f"#define PROTOBUF_MAJOR_VERSION {git_major}", -- 2.43.0