Skip to content

Commit

Permalink
info patchlevel: now returns git version if available
Browse files Browse the repository at this point in the history
e.g.

. info patchlevel
0.83-35-g8a438c3-dirty

Fixes #297

Signed-off-by: Steve Bennett <[email protected]>
  • Loading branch information
msteveb committed Sep 22, 2024
1 parent 8a438c3 commit f055961
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
7 changes: 6 additions & 1 deletion auto.def
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,11 @@ if {[opt-bool shared with-jim-shared]} {
define JIM_STATICLIB
}
define VERSION [format %.2f [expr {[get-define JIM_VERSION] / 100.0}]]
set githash [get-define VERSION]
catch {
set githash [exec git describe --dirty]
}
define JIM_GITVERSION $githash
define LIBSOEXT [format [get-define SH_SOEXTVER] [get-define VERSION]]
if {[get-define libdir] ni {/lib /usr/lib /usr/lib64}} {
define SH_LINKRPATH_FLAGS [format [get-define SH_LINKRPATH] [get-define libdir]]
Expand Down Expand Up @@ -669,7 +674,7 @@ foreach mod $extinfo(module-c) {
}
define BUILD_SHOBJS [join $lines \n]

make-config-header jim-config.h -auto {HAVE_LONG_LONG* JIM_UTF8 JIM_TAINT SIZEOF_INT} -bare JIM_VERSION -none *
make-config-header jim-config.h -auto {HAVE_LONG_LONG* JIM_UTF8 JIM_TAINT JIM_GITVERSION SIZEOF_INT} -bare JIM_VERSION -none *
make-config-header jimautoconf.h -auto {jim_ext_* TCL_PLATFORM_* TCL_LIBRARY USE_* JIM_* _FILE_OFFSET*} -bare {S_I*}
make-template Makefile.in
make-template tests/Makefile.in
Expand Down
14 changes: 8 additions & 6 deletions jim.c
Original file line number Diff line number Diff line change
Expand Up @@ -16092,15 +16092,17 @@ static int Jim_InfoCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *arg
return JIM_OK;
}

case INFO_VERSION:
case INFO_PATCHLEVEL:{
char buf[(JIM_INTEGER_SPACE * 2) + 1];

sprintf(buf, "%d.%d", JIM_VERSION / 100, JIM_VERSION % 100);
Jim_SetResultString(interp, buf, -1);
case INFO_VERSION:{
char versionbuf[64];
snprintf(versionbuf, sizeof(versionbuf), "%d.%d", JIM_VERSION / 100, JIM_VERSION % 100);
Jim_SetResultString(interp, versionbuf, -1);
return JIM_OK;
}

case INFO_PATCHLEVEL:
Jim_SetResultString(interp, JIM_GITVERSION, -1);
return JIM_OK;

case INFO_COMPLETE: {
char missing;

Expand Down

0 comments on commit f055961

Please sign in to comment.