From 977a0ce287b1c45c59f9f8d75d573695abcd3f2a Mon Sep 17 00:00:00 2001
From: Damien George <damien.p.george@gmail.com>
Date: Sat, 3 May 2014 19:02:14 +0100
Subject: [PATCH] py: Print tag/version/git describe in uPy banner.

---
 py/py-version.sh | 2 ++
 stmhal/pyexec.c  | 2 +-
 unix/main.c      | 2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/py/py-version.sh b/py/py-version.sh
index f574b574f..53063381f 100755
--- a/py/py-version.sh
+++ b/py/py-version.sh
@@ -1,5 +1,6 @@
 #!/bin/bash
 
+git_tag="$(git describe || echo unknown)"
 git_hash="$(git rev-parse --short HEAD 2> /dev/null || echo unknown)"
 git_files_are_clean=1
 # Check if there are any modified files.
@@ -11,6 +12,7 @@ if [ "${git_files_are_clean}" != "1" ]; then
 fi
 cat <<EOF
 // This file was generated by py/py-version.sh
+#define MICROPY_GIT_TAG "${git_tag}"
 #define MICROPY_GIT_HASH "${git_hash}"
 #define MICROPY_BUILD_DATE "$(date '+%Y-%m-%d')"
 EOF
diff --git a/stmhal/pyexec.c b/stmhal/pyexec.c
index 294020cec..ded20e148 100644
--- a/stmhal/pyexec.c
+++ b/stmhal/pyexec.c
@@ -155,7 +155,7 @@ int pyexec_friendly_repl(void) {
 #endif
 
 friendly_repl_reset:
-    stdout_tx_str("Micro Python build " MICROPY_GIT_HASH " on " MICROPY_BUILD_DATE "; " MICROPY_HW_BOARD_NAME " with STM32F405RG\r\n");
+    stdout_tx_str("Micro Python " MICROPY_GIT_TAG " (" MICROPY_GIT_HASH " on " MICROPY_BUILD_DATE "); " MICROPY_HW_BOARD_NAME " with STM32F405RG\r\n");
     stdout_tx_str("Type \"help()\" for more information.\r\n");
 
     // to test ctrl-C
diff --git a/unix/main.c b/unix/main.c
index e677ff65d..3fd611328 100644
--- a/unix/main.c
+++ b/unix/main.c
@@ -142,7 +142,7 @@ STATIC char *prompt(char *p) {
 }
 
 STATIC void do_repl(void) {
-    printf("Micro Python build " MICROPY_GIT_HASH " on " MICROPY_BUILD_DATE "; UNIX version\n");
+    printf("Micro Python " MICROPY_GIT_TAG " (" MICROPY_GIT_HASH " on " MICROPY_BUILD_DATE "); UNIX version\n");
 
     for (;;) {
         char *line = prompt(">>> ");
-- 
GitLab