From 480b0bf9797e32398b494a30ebf56101ec35033b Mon Sep 17 00:00:00 2001 From: pk910 Date: Thu, 6 Sep 2012 13:41:35 +0200 Subject: [PATCH] changed version numbering (separate stable and dev versions) --- src/modules.c | 5 +++- src/modules/global.mod/cmd_global_netinfo.c | 2 +- src/modules/global.mod/cmd_global_version.c | 2 +- src/modules/module.h | 2 ++ src/version.h | 4 +++ src/version.sh | 29 ++++++++++++++++++--- 6 files changed, 37 insertions(+), 7 deletions(-) diff --git a/src/modules.c b/src/modules.c index b451c0d..5e0c826 100644 --- a/src/modules.c +++ b/src/modules.c @@ -48,6 +48,7 @@ /* 190 */ /* UserNode.h */ /* 191-193 */ #include "ModuleFunctions.h" /* 194 */ /* bots.h */ +/* 195-196 */ /* version.h */ #define Function void * @@ -257,7 +258,9 @@ void *global_functions[] = { /* 191 */ (Function) module_global_cmd_register_neonbackup, /* 192 */ (Function) module_global_cmd_unregister_neonbackup, /* 193 */ (Function) module_neonbackup_recover_chan, -/* 194 */ (Function) requestInvite +/* 194 */ (Function) requestInvite, +/* 195 */ (Function) is_stable_revision, +/* 196 */ (Function) get_dev_revision }; static int module_id_counter = 1; diff --git a/src/modules/global.mod/cmd_global_netinfo.c b/src/modules/global.mod/cmd_global_netinfo.c index 9deeafa..02a0426 100644 --- a/src/modules/global.mod/cmd_global_netinfo.c +++ b/src/modules/global.mod/cmd_global_netinfo.c @@ -152,7 +152,7 @@ CMD_BIND(global_cmd_netinfo) { #endif if(strcmp(get_revision(), "")) - sprintf(tmp, "%s.%d (%s)", NEONSERV_VERSION, get_patchlevel(), get_revision()); + sprintf(tmp, "%s.%d (%s: %s)", NEONSERV_VERSION, get_patchlevel(), (is_stable_revision() ? "stable" : "dev"), (is_stable_revision() ? get_revision() : get_dev_revision())); else sprintf(tmp, "%s.%d", NEONSERV_VERSION, get_patchlevel()); content[0] = get_language_string(user, "NS_NETINFO_VERSION"); diff --git a/src/modules/global.mod/cmd_global_version.c b/src/modules/global.mod/cmd_global_version.c index faa03ac..77ccb74 100644 --- a/src/modules/global.mod/cmd_global_version.c +++ b/src/modules/global.mod/cmd_global_version.c @@ -22,7 +22,7 @@ */ CMD_BIND(global_cmd_version) { - reply(textclient, user, "\002NeonServ %s.%d\002 (%s), written by pk910", NEONSERV_VERSION, get_patchlevel(), (strcmp(get_revision(), "") ? get_revision() : "-")); + reply(textclient, user, "\002NeonServ %s.%d %s\002 (%s), written by pk910", NEONSERV_VERSION, get_patchlevel(), (is_stable_revision() ? "(stable)" : "(dev)"), (is_stable_revision() ? (strcmp(get_revision(), "") ? get_revision() : "-") : get_dev_revision())); reply(textclient, user, "Build (#%s) %s (%s lines, " COMPILER ")", get_compilation(), get_creation(), get_codelines()); reply(textclient, user, "NeonServ can be found on: http://dev.pk910.de/NeonServ"); //helpers :D diff --git a/src/modules/module.h b/src/modules/module.h index 1a8426c..d5b1d7a 100644 --- a/src/modules/module.h +++ b/src/modules/module.h @@ -224,6 +224,8 @@ extern int module_id; /* 192 */ #define module_global_cmd_unregister_neonbackup ((void (*)(char *))global[192]) /* 193 */ #define module_neonbackup_recover_chan ((void (*)(struct ChanNode *))global[193]) /* 194 */ #define requestInvite ((void (*)(struct UserNode *, struct ChanNode *))global[194]) +/* 195 */ #define is_stable_revision ((const int (*)(void))global[195]) +/* 196 */ #define get_dev_revision ((const char * (*)(void))global[196]) #define MODULE_HEADER(initfunc,startfunc,stopfunc) \ void **global = NULL; \ diff --git a/src/version.h b/src/version.h index 2b653c2..dec5d86 100644 --- a/src/version.h +++ b/src/version.h @@ -26,11 +26,15 @@ extern const char *compilation; extern const char *creation; extern const char *revision; extern const char *codelines; +extern const int revision_master; +extern const char *dev_revision; extern const int patchlevel; const char *get_compilation(); const char *get_creation(); const char *get_revision(); +const int is_stable_revision(); +const char *get_dev_revision(); const char *get_codelines(); const int get_patchlevel(); #endif diff --git a/src/version.sh b/src/version.sh index a7c712f..68a8e4f 100755 --- a/src/version.sh +++ b/src/version.sh @@ -20,13 +20,24 @@ else \ codelines=`find . -type f -regex '\./.*\.h' -or -regex '\./.*\.c' |xargs cat|wc -l` -git_revision=`git rev-list -n 1 --pretty="format:%h" --header master | grep '^[0-9a-f]*$'` -if test "x$git_revision" = "x" ; then +git_revision_id=`git rev-list -n 1 --pretty="format:%h" --header refs/heads/master | grep '^[0-9a-f]*$'` +if test "x$git_revision_id" = "x" ; then git_revision="0" git_commitcount="0" + git_is_stable="1" + git_dev_rev="" else - git_commitcount=`git rev-list --oneline --header master | wc -l | sed "s/[ \t]//g"` - git_revision="git-$git_commitcount-$git_revision" + git_commitcount=`git rev-list --oneline --first-parent refs/heads/master | wc -l | sed "s/[ \t]//g"` + git_revision="git-$git_revision_id" + + git_real_revision_id=`git rev-list -n 1 --pretty="format:%h" --header HEAD | grep '^[0-9a-f]*$'` + if test "$git_revision_id" = "$git_real_revision_id" ; then + git_is_stable="1" + git_dev_rev="" + else + git_is_stable="0" + git_dev_rev="git-$git_real_revision_id" + fi fi @@ -55,6 +66,8 @@ const char *compilation = "$compilation"; const char *creation = "$creation"; const char *revision = "$git_revision"; const char *codelines = "$codelines"; +const int revision_master = $git_is_stable; +const char *dev_revision = "$git_dev_rev"; const int patchlevel = ($git_commitcount ? ($git_commitcount - VERSION_PATCHLEVEL) : 0); @@ -74,6 +87,14 @@ const char *get_codelines() { return codelines; } +const int is_stable_revision() { + return revision_master; +} + +const char *get_dev_revision() { + return dev_revision; +} + const int get_patchlevel() { return patchlevel; } -- 2.20.1