depot/nix/pkgs/flipperzero-firmware/0002-proto_ver_generator-use-changelog-not-git.patch

53 lines
1.7 KiB
Diff

From 02bd53dd56448d44770723dcc3885dbef37d2da8 Mon Sep 17 00:00:00 2001
From: Luke Granger-Brown <git@lukegb.com>
Date: Sat, 22 Oct 2022 19:35:00 +0100
Subject: [PATCH 2/5] proto_ver_generator: use changelog, not git
---
scripts/fbt_tools/fbt_assets.py | 28 ++++++++++------------------
1 file changed, 10 insertions(+), 18 deletions(-)
diff --git a/scripts/fbt_tools/fbt_assets.py b/scripts/fbt_tools/fbt_assets.py
index 68617c254..e7afb2d5c 100644
--- a/scripts/fbt_tools/fbt_assets.py
+++ b/scripts/fbt_tools/fbt_assets.py
@@ -73,26 +73,18 @@ 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
- try:
- _invoke_git(
- ["fetch", "--tags"],
- source_dir=src_dir,
- )
- except (subprocess.CalledProcessError, EnvironmentError):
- # Not great, not terrible
- print(fg.boldred("Git: fetch failed"))
-
- try:
- git_describe = _invoke_git(
- ["describe", "--tags", "--abbrev=0"],
- source_dir=src_dir,
- )
- except (subprocess.CalledProcessError, EnvironmentError):
- raise StopError("Git: describe failed")
- 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.40.1