msteveb / jimtcl

Official repository of Jim Tcl, an open-source, small footprint implementation of Tcl
http://jim.tcl.tk/
Other
432 stars 123 forks source link

Add git hash to version number display #297

Open prpr19xx opened 6 months ago

prpr19xx commented 6 months ago

It would be useful to add the the git hash to the output from jimsh --version Rather than just outputting e.g. "0.82", it could output with some or all of the git describe output e.g. "0.82-82-ge23aea2" or "0.82 e23aea2" or "0.82 0.82-82-ge23aea2" or whatever format you think best.

The-Markitecht commented 1 week ago

I'd like that info available also. It also sounds appropriate to return from info patchlevel but not info version, if those are distinct implementations already.

msteveb commented 1 week ago

I pushed the 'info patchlevel' change to master-next for testing

prpr19xx commented 1 week ago

This is OK as far as it goes, but I was hoping for something a bit more obvious without having to start running commands.

diff --git a/jim-interactive.c b/jim-interactive.c
index ba3ed65..4a747b5 100644
--- a/jim-interactive.c
+++ b/jim-interactive.c
@@ -287,8 +287,13 @@ int Jim_InteractivePrompt(Jim_Interp *interp)
     Jim_HistorySetHints(interp, Jim_NewStringObj(interp, "tcl::stdhint", -1));
 #endif

+#ifdef JIM_GITVERSION
+    printf("Welcome to Jim version %d.%d (%s)\n",
+        JIM_VERSION / 100, JIM_VERSION % 100, JIM_GITVERSION);
+#else
     printf("Welcome to Jim version %d.%d\n",
         JIM_VERSION / 100, JIM_VERSION % 100);
+#endif
     Jim_SetVariableStrWithStr(interp, JIM_INTERACTIVE, "1");

     while (1) {
diff --git a/jimsh.c b/jimsh.c
index 6104afb..da9b2e9 100644
--- a/jimsh.c
+++ b/jimsh.c
@@ -90,7 +90,11 @@ int main(int argc, char *const argv[])

     /* Parse initial arguments before interpreter is started */
     if (argc > 1 && strcmp(argv[1], "--version") == 0) {
+#ifdef JIM_GITVERSION
+        printf("%d.%d (%s)\n", JIM_VERSION / 100, JIM_VERSION % 100, JIM_GITVERSION);
+#else
         printf("%d.%d\n", JIM_VERSION / 100, JIM_VERSION % 100);
+#endif
         return 0;
     }
     else if (argc > 1 && strcmp(argv[1], "--help") == 0) {

gives: $ ./jimsh --version 0.84 (0.83-36-gf827205) $ ./jimsh Welcome to Jim version 0.84 (0.83-36-gf827205) . info version 0.84 . info patchlevel 0.83-36-gf827205

msteveb commented 1 week ago

OK, but why is this necessary. The git hash should be mostly of idle curiosity. And it's easy enough to get directly from the command line.

$ ./jimsh -e 'info patchlevel' 0.83-39-g683e0af2