From 9e89c752cb911ec9b4d3dd4d2edd6714e7ad09aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20de=20Giessen?= Date: Thu, 10 Jul 2025 18:57:55 +0200 Subject: [PATCH] py/makeversionhdr.py: Always abbreviate Git hashes to same length. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Git hash is embedded in the version number. The hash is abbreviated by Git. This commit changes the length of the Git hash abbreviation to a fixed number, so that the length of the version string no longer varies based on external factors (it can still vary, but will now be at least 10 characters). This change is made because builds of the same MicroPython commit on multiple machines were sometimes giving a version string with different lengths, eg due to commits on other local branches having a clashing abbreviated hash. This change may also help the code size report to be more consistent, because it will less often be impacted by random changes in the version string length, at the cost of always being a few bytes longer. Signed-off-by: Daniƫl van de Giessen --- py/makeversionhdr.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/py/makeversionhdr.py b/py/makeversionhdr.py index 406a061a09..5c73501b3b 100644 --- a/py/makeversionhdr.py +++ b/py/makeversionhdr.py @@ -31,7 +31,16 @@ def get_version_info_from_git(repo_path): # Note: git describe doesn't work if no tag is available try: git_tag = subprocess.check_output( - ["git", "describe", "--tags", "--dirty", "--always", "--match", "v[1-9].*"], + [ + "git", + "describe", + "--tags", + "--dirty", + "--always", + "--match", + "v[1-9].*", + "--abbrev=10", + ], cwd=repo_path, stderr=subprocess.STDOUT, universal_newlines=True,