[mw-devel] [Git][arthur/mw][master] 2 commits: Simplify version numbering using git tags
Andrew Price
welshbyte at sucs.org
Fri Jan 15 18:46:45 GMT 2016
Andrew Price pushed to branch master at Justin Mitchell / mw
Commits:
9325a02d by Andrew Price at 2016-01-15T18:35:02Z
Simplify version numbering using git tags
As we're determined to use git for providing version numbers we might as
well do it the right way. Take all of the version information from git
describe. This assumes that at least one annotated tag exists in the
branch relating to a release. The tag will be created using
$ git tag -a -m "Version 2.17" 2.17 fb1be771949e595952fdf83aac1c8649696d9f81
so git describe will give us versions like 2.17-123-gf00baa which has
better ordering properties than the current 2.17-gf00baa scheme, which
is important for package upgrades. When HEAD matches the tag exactly, it
will just give 2.17
- - - - -
79336cc6 by Andrew Price at 2016-01-15T18:37:19Z
Add -dirty to the version string if there are uncommitted changes
- - - - -
7 changed files:
- Makefile
- Makefile.common
- src/client/init.c
- src/client/js.c
- src/client/main.c
- src/client/script_inst.c
- src/server/servsock.c
Changes:
=====================================
Makefile
=====================================
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@ build:
$(MAKE) -C src $@
$(MAKE) -C po $@
-ifeq ($(SVNVER),)
+ifeq ($(GITVER),)
# These rules can only be called from inside an exported tree
install:
install -d $(DESTDIR)$(libdir)/mw
@@ -19,7 +19,7 @@ install:
deb:
cp -a debian-template debian
dch --create --package mw3 -v $(VERSION) -c debian/changelog "Build mw3 $(VERSION) package"
- debuild -e VERSION_TWEAK=$(VERSION_TWEAK) -us -uc -b
+ debuild -e VERSION=$(VERSION) -us -uc -b
tarball:
tar zchvf ../$(MWVERSION).tar.gz -C .. $(MWVERSION)
@@ -35,7 +35,7 @@ export:
rm -rf $(TMPDIR)/$(MWVERSION)
git checkout-index -a -f --prefix=$(TMPDIR)/$(MWVERSION)/
# Store the git hash so we know it in the exported directory
- echo $(VERSION_TWEAK) > $(TMPDIR)/$(MWVERSION)/mw.rev
+ echo $(GITVER) > $(TMPDIR)/$(MWVERSION)/mw.rev
install tarball rpm: export
$(MAKE) -C $(TMPDIR)/$(MWVERSION) $@
=====================================
Makefile.common
=====================================
--- a/Makefile.common
+++ b/Makefile.common
@@ -1,23 +1,13 @@
SHELL = /bin/bash
-SVNVER = $(shell git describe --always )
-
-VERSION_MAJOR = 2
-VERSION_MINOR = 17
-
-ifeq ($(VERSION_TWEAK),)
-ifeq ($(SVNVER),)
-# mw.rev is created after an export so we can rely on it to provide the git hash here
-VERSION_TWEAK = $(shell cat $(SRCROOT)/mw.rev)
-else
-ifeq ($(SVNVER),0)
-$(warning failed to get git revision. VERSION_TWEAK will be set to 0)
-endif
-VERSION_TWEAK = $(SVNVER)
-endif
+GITVER = $(shell git describe --always --dirty)
+VERSION = $(GITVER)
+
+ifeq ($(VERSION),)
+# mw.rev is created after an export so we can rely on it to provide the version here
+VERSION = $(shell cat $(SRCROOT)/mw.rev)
endif
-VERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_TWEAK)
MWVERSION = mw3-$(VERSION)
prefix ?= /usr
@@ -58,9 +48,7 @@ endif
# info strings, do not edit.
DEFS:= -DBUILD_DATE=\"$(shell date +%Y%m%d)\"
DEFS+= -DBUILD_USER=\"$(shell whoami | sed 's/^./\u&/')\"
-DEFS+= -DVER_MAJ=\"$(VERSION_MAJOR)\"
-DEFS+= -DVER_MIN=\"$(VERSION_MINOR)\"
-DEFS+= -DVER_TWK=\"$(VERSION_TWEAK)\"
+DEFS+= -DVERSION=\"$(VERSION)\"
DEFS+= -DHOMEPATH=\"$(HOMEPATH)\"
DEFS+= -DLOGDIR=\"$(LOGDIR)\"
DEFS+= -DSTATEDIR=\"$(STATEDIR)\"
=====================================
src/client/init.c
=====================================
--- a/src/client/init.c
+++ b/src/client/init.c
@@ -66,10 +66,7 @@ static int ReadInitFile(const char *base, const char *filename)
curl_easy_setopt(cl, CURLOPT_WRITEDATA, file);
curl_easy_setopt(cl, CURLOPT_URL, filename);
curl_easy_setopt(cl, CURLOPT_ERRORBUFFER, cerr);
- if (atoi(VER_TWK) > 0)
- curl_easy_setopt(cl, CURLOPT_USERAGENT, "Milliways III v" VER_MAJ "." VER_MIN "." VER_TWK);
- else
- curl_easy_setopt(cl, CURLOPT_USERAGENT, "Milliways III v" VER_MAJ "." VER_MIN);
+ curl_easy_setopt(cl, CURLOPT_USERAGENT, "Milliways III v" VERSION);
if (curl_easy_perform(cl))
fprintf(stderr, "Error loading %s: %s\n", filename, cerr);
curl_easy_cleanup(cl);
=====================================
src/client/js.c
=====================================
--- a/src/client/js.c
+++ b/src/client/js.c
@@ -780,10 +780,7 @@ static JSBool js_urlget(JSContext *cx, unsigned int argc, jsval *vp)
curl_easy_setopt(cl, CURLOPT_WRITEDATA, answer);
curl_easy_setopt(cl, CURLOPT_URL, url);
curl_easy_setopt(cl, CURLOPT_ERRORBUFFER, cerr);
- if (atoi(VER_TWK) > 0)
- curl_easy_setopt(cl, CURLOPT_USERAGENT, "Milliways III v" VER_MAJ "." VER_MIN "." VER_TWK);
- else
- curl_easy_setopt(cl, CURLOPT_USERAGENT, "Milliways III v" VER_MAJ "." VER_MIN);
+ curl_easy_setopt(cl, CURLOPT_USERAGENT, "Milliways III v" VERSION);
if (curl_easy_perform(cl)) {
snprintf(msg, MAXTEXTLENGTH-1, "JavaScript urlget failed %s: %s", url, cerr);
js_warning(cx, msg);
=====================================
src/client/main.c
=====================================
--- a/src/client/main.c
+++ b/src/client/main.c
@@ -51,7 +51,7 @@
#include "who.h"
#include "alias.h"
-static char version[]="Milliways III - Release "VER_MAJ"."VER_MIN"."VER_TWK"\n";
+static char version[]="Milliways III - Release "VERSION"\n";
/* global termcap usage variable */
int g_boTermCap = 0;
@@ -1858,10 +1858,7 @@ char *part_comm_mesg(const char *text, int status)
void c_version(CommandList *cm, int argc, const char **argv, char *args)
{
- if (atoi(VER_TWK) > 0)
- printf(_("Version %s.%s.%s\n"), VER_MAJ, VER_MIN, VER_TWK);
- else
- printf(_("Version %s.%s\n"), VER_MAJ, VER_MIN);
+ printf(_("Version "VERSION"\n"));
printf(_("Built by %s on %s\n"), BUILD_USER, __DATE__);
}
=====================================
src/client/script_inst.c
=====================================
--- a/src/client/script_inst.c
+++ b/src/client/script_inst.c
@@ -2032,15 +2032,14 @@ void scr_user( struct code *pc, int fargc, char **fargv )
void scr_version( struct code *pc, int fargc, char **fargv )
{
char *what;
- const char *version_str = "R "VER_MAJ" "VER_MIN;
if (pc->argc < 1) {
if (script_debug) printf("Error in %s at %s too few arguments.\n", pc->inst->name, pc->debug);
return;
}
what=eval_arg(pc->argv[0], fargc, fargv);
- if (script_debug) printf(" - VERSION: Version string is '%s'", version_str);
- var_str_force_2(what, version_str);
+ if (script_debug) printf(" - VERSION: Version string is '%s'", VERSION);
+ var_str_force_2(what, VERSION);
free(what);
}
=====================================
src/server/servsock.c
=====================================
--- a/src/server/servsock.c
+++ b/src/server/servsock.c
@@ -311,9 +311,7 @@ void process_msg(ipc_connection_t *conn, ipc_message_t *msg)
json_t * j = json_init(NULL);
json_addint(j, "uptime", now - uptime);
- _autofree char *version = NULL;
- asprintf(&version, "%s.%s.%s", VER_MAJ, VER_MIN, VER_TWK);
- json_addstring(j, "version", version);
+ json_addstring(j, "version", VERSION);
ipcmsg_json_encode(msg, j);
msg_attach(msg, conn);
ipcmsg_destroy(msg);
View it on GitLab: https://projects.sucs.org/arthur/mw/compare/cc3727d6eef5ef2781ef85a9a762a48935c04acc...79336cc6e46c88ba3c70f4208536afe9688ee491
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sucs.org/pipermail/mw-devel/attachments/20160115/2775048f/attachment.html>
More information about the mw-devel
mailing list