Make jq --version report an actual git revision.

Closes #129.
This commit is contained in:
Stephen Dolan committed 2013-05-24 23:35:38 +01:00
1 parent cbd422d56e
commit f0b982795c
4 files changed
+14 -7

No files matched your search

+1
View File
@@ -26,3 +26,4 @@ jq-*.tar.gz
configure
aclocal.m4
Makefile.in
version.h
+5 -5
View File
@@ -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 ..."
+3 -2
View File
@@ -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]);
+5
View File
@@ -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-//'