diff options
author | Stephen Dolan <mu@netsoc.tcd.ie> | 2013-05-24 23:34:34 +0100 |
---|---|---|
committer | Stephen Dolan <mu@netsoc.tcd.ie> | 2013-05-24 23:35:38 +0100 |
commit | f0b982795c19ff6517e564f4757791df2228db4c (patch) | |
tree | 7d236093cb12d2eb318633409cb3a2702bc5778a | |
parent | cbd422d56ecc9e0a3703db34cfc6c87a5c5fcd3a (diff) |
Make jq --version report an actual git revision.
Closes #129.
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile.am | 10 | ||||
-rw-r--r-- | main.c | 5 | ||||
-rwxr-xr-x | scripts/version | 5 |
4 files changed, 14 insertions, 7 deletions
@@ -26,3 +26,4 @@ jq-*.tar.gz configure aclocal.m4 Makefile.in +version.h diff --git a/Makefile.am b/Makefile.am index 5508e9a2..23e9d253 100644 --- a/Makefile.am +++ b/Makefile.am @@ -33,7 +33,10 @@ AM_YFLAGS = --warnings=all -d ### Building the jq binary -main.c: config.h +version.h: + @ { $(srcdir)/scripts/version || echo '$(VERSION)'; } | sed 's/.*/#define JQ_VERSION "&"/'> $@ + +main.c: config.h version.h bin_PROGRAMS = jq jq_SOURCES = ${JQ_SRC} main.c @@ -95,16 +98,13 @@ DOC_FILES = docs/content docs/public docs/templates docs/site.yml \ # the developer setup script in the tarball. EXTRA_DIST = config.h.in $(BUILT_SOURCES) $(man_MANS) $(TESTS) \ $(TEST_LOG_COMPILER) gen_utf8_tables.py jq.spec \ - $(DOC_FILES) + $(DOC_FILES) scripts/version # README.md is expected in Github projects, good stuff in it, so we'll # distribute it and install it with the package in the doc directory. docdir = ${datadir}/doc/${PACKAGE} dist_doc_DATA = README.md COPYING AUTHORS README -releasetag: - git tag -s "jq-$$(cat VERSION)" -m "jq release $$(cat VERSION)" - RELEASE ?= 1 rpm: jq @echo "Packaging jq as an RPM ..." @@ -9,13 +9,14 @@ #include "execute.h" #include "config.h" /* Autoconf generated header file */ #include "jv_alloc.h" +#include "version.h" int jq_testsuite(int argc, char* argv[]); static const char* progname; static void usage() { - fprintf(stderr, "\njq - commandline JSON processor [version %s]\n", PACKAGE_VERSION); + fprintf(stderr, "\njq - commandline JSON processor [version %s]\n", JQ_VERSION); fprintf(stderr, "Usage: %s [options] <jq filter> [file...]\n\n", progname); fprintf(stderr, "For a description of the command line options and\n"); fprintf(stderr, "how to write jq filters (and why you might want to)\n"); @@ -238,7 +239,7 @@ int main(int argc, char* argv[]) { } else if (isoption(argv[i], 'h', "help")) { usage(); } else if (isoption(argv[i], 'V', "version")) { - fprintf(stderr, "jq version %s\n", PACKAGE_VERSION); + fprintf(stderr, "jq-%s\n", JQ_VERSION); return 0; } else { fprintf(stderr, "%s: Unknown option %s\n", progname, argv[i]); diff --git a/scripts/version b/scripts/version new file mode 100755 index 00000000..fb941a00 --- /dev/null +++ b/scripts/version @@ -0,0 +1,5 @@ +#!/bin/sh +set -e +cd `dirname "$0"` +git rev-parse --verify -q jq-1.0 > /dev/null 2>&1 +git describe --always --match 'jq-*' --dirty | sed 's/^jq-//' |