summaryrefslogtreecommitdiffstats
path: root/lib/python/qmk/cli/generate
diff options
context:
space:
mode:
authorPablo Martínez <58857054+elpekenin@users.noreply.github.com>2023-02-02 19:23:27 +0100
committerGitHub <noreply@github.com>2023-02-02 18:23:27 +0000
commitd55b07696b59d6e4bb427e22ed171a4e23c95a2b (patch)
tree715875bd521c2b75be0fce47ba469b4d827c98a1 /lib/python/qmk/cli/generate
parent53132ab9cf3b7478c0e293fc1f3eab2203598a48 (diff)
Add commit info to `version.h` (#19542)
* Initial commit * Fix import order * Fix deleted code instead of debug print line * Format * Update lib/python/qmk/cli/generate/version_h.py Co-authored-by: Ryan <fauxpark@gmail.com> * Renaming * Update lib/python/qmk/cli/generate/version_h.py Co-authored-by: Joel Challis <git@zvecr.com> * Update lib/python/qmk/git.py Co-authored-by: Joel Challis <git@zvecr.com> --------- Co-authored-by: Ryan <fauxpark@gmail.com> Co-authored-by: Joel Challis <git@zvecr.com>
Diffstat (limited to 'lib/python/qmk/cli/generate')
-rw-r--r--lib/python/qmk/cli/generate/version_h.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/python/qmk/cli/generate/version_h.py b/lib/python/qmk/cli/generate/version_h.py
index a75702c529..fd87df3617 100644
--- a/lib/python/qmk/cli/generate/version_h.py
+++ b/lib/python/qmk/cli/generate/version_h.py
@@ -6,7 +6,7 @@ from milc import cli
from qmk.path import normpath
from qmk.commands import dump_lines
-from qmk.git import git_get_version
+from qmk.git import git_get_qmk_hash, git_get_version, git_is_dirty
from qmk.constants import GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE
TIME_FMT = '%Y-%m-%d-%H:%M:%S'
@@ -29,23 +29,30 @@ def generate_version_h(cli):
current_time = strftime(TIME_FMT)
if cli.args.skip_git:
+ git_dirty = False
git_version = "NA"
+ git_qmk_hash = "NA"
chibios_version = "NA"
chibios_contrib_version = "NA"
else:
+ git_dirty = git_is_dirty()
git_version = git_get_version() or current_time
+ git_qmk_hash = git_get_qmk_hash() or "Unknown"
chibios_version = git_get_version("chibios", "os") or current_time
chibios_contrib_version = git_get_version("chibios-contrib", "os") or current_time
# Build the version.h file.
version_h_lines = [GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE, '#pragma once']
- version_h_lines.append(f"""
+ version_h_lines.append(
+ f"""
#define QMK_VERSION "{git_version}"
#define QMK_BUILDDATE "{current_time}"
+#define QMK_GIT_HASH "{git_qmk_hash}{'*' if git_dirty else ''}"
#define CHIBIOS_VERSION "{chibios_version}"
#define CHIBIOS_CONTRIB_VERSION "{chibios_contrib_version}"
-""")
+"""
+ )
# Show the results
dump_lines(cli.args.output, version_h_lines, cli.args.quiet)