* [PATCH] guilt: add git commit level versioning
@ 2008-10-08 2:08 Paul Gortmaker
2008-10-09 15:54 ` Josef 'Jeff' Sipek
0 siblings, 1 reply; 3+ messages in thread
From: Paul Gortmaker @ 2008-10-08 2:08 UTC (permalink / raw)
To: jeffpc; +Cc: git
Shamelessly steal the dynamic versioning goodies from git
itself. Now when you do "guilt --version" you can expect to
see things like:
Guilt version 0.31.2.14.gece1.dirty
assuming you've 14 commits since 0.31.2 and also some changes
that you've not committed yet.
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
.gitignore | 2 ++
Documentation/Makefile | 4 ++--
GUILT-VERSION-GEN | 42 ++++++++++++++++++++++++++++++++++++++++++
Makefile | 21 ++++++++++++++++-----
guilt | 4 +++-
5 files changed, 65 insertions(+), 8 deletions(-)
create mode 100755 GUILT-VERSION-GEN
diff --git a/.gitignore b/.gitignore
index c81112b..61161ef 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,5 @@
#
*~
*.swp
+guilt.bin
+GUILT-VERSION-FILE
diff --git a/Documentation/Makefile b/Documentation/Makefile
index 9fc1165..4b7d037 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -7,7 +7,7 @@ DOC_MAN1=$(patsubst %.txt,%.1,$(MAN1_TXT))
DOC_MAN7=$(patsubst %.txt,%.7,$(MAN7_TXT))
USAGE=$(patsubst %.txt,usage-%.txt,$(MAN1_TXT))
-VERSION=$(shell git describe 2> /dev/null || sed -n -e '/^GUILT_VERSION=/ { s/^GUILT_VERSION="/v/; s/"//; p; q; }' ../guilt)
+include ../GUILT-VERSION-FILE
prefix?=$(PREFIX)
bindir?=$(prefix)/bin
@@ -51,7 +51,7 @@ doc.dep : $(wildcard *.txt) build-docdep.perl
-include doc.dep
version.txt:
- echo "(Generated for Guilt $(VERSION))" > version.txt
+ echo "(Generated for Guilt $(GUILT_VERSION))" > version.txt
cmds.txt: cmd-list.sh $(MAN1_TXT)
sh ./cmd-list.sh
diff --git a/GUILT-VERSION-GEN b/GUILT-VERSION-GEN
new file mode 100755
index 0000000..66b40e2
--- /dev/null
+++ b/GUILT-VERSION-GEN
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+GVF=GUILT-VERSION-FILE
+DEF_VER=v0.31.2
+
+LF='
+'
+
+# First see if there is a version file (included in release tarballs),
+# then try git-describe, then default.
+if test -f version
+then
+ VN=$(cat version) || VN="$DEF_VER"
+elif test -d .git -o -f .git &&
+ VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
+ case "$VN" in
+ *$LF*) (exit 1) ;;
+ v[0-9]*)
+ git update-index -q --refresh
+ test -z "$(git diff-index --name-only HEAD --)" ||
+ VN="$VN-dirty" ;;
+ esac
+then
+ VN=$(echo "$VN" | sed -e 's/-/./g');
+else
+ VN="$DEF_VER"
+fi
+
+VN=$(expr "$VN" : v*'\(.*\)')
+
+if test -r $GVF
+then
+ VC=$(sed -e 's/^GUILT_VERSION = //' <$GVF)
+else
+ VC=unset
+fi
+test "$VN" = "$VC" || {
+ echo >&2 "GUILT_VERSION=$VN"
+ echo "GUILT_VERSION=$VN" >$GVF
+}
+
+
diff --git a/Makefile b/Makefile
index af53fb5..f3cf0b3 100644
--- a/Makefile
+++ b/Makefile
@@ -1,25 +1,35 @@
PREFIX=/usr/local
DESTDIR=
-SCRIPTS = guilt \
- $(filter-out $(wildcard *~),$(wildcard guilt-*))
+SCRIPTS = $(filter-out $(wildcard *~),$(wildcard guilt-*))
-.PHONY: all
-all: doc
+all::
+
+.PHONY: .FORCE-GUILT-VERSION-FILE
+GUILT-VERSION-FILE: .FORCE-GUILT-VERSION-FILE
+ @$(SHELL_PATH) ./GUILT-VERSION-GEN
+-include GUILT-VERSION-FILE
+
+.PHONY: all
+all:: doc guilt.bin
@echo "Nothing to build, it is all bash :)"
@echo "Try make install"
+guilt.bin: GUILT-VERSION-FILE
+ @sed 's/^GUILT_VERSION=$$/GUILT_VERSION="$(GUILT_VERSION)"/' < guilt > guilt.bin
+
.PHONY: install
install:
install -d $(DESTDIR)$(PREFIX)/bin/
install -m 755 $(SCRIPTS) $(DESTDIR)$(PREFIX)/bin/
+ install -m 755 guilt.bin $(DESTDIR)$(PREFIX)/bin/guilt
.PHONY: uninstall
uninstall:
./uninstall $(DESTDIR)$(PREFIX)/bin/ $(SCRIPTS)
.PHONY: doc
-doc:
+doc: GUILT-VERSION-FILE
$(MAKE) -C Documentation all
.PHONY: install-doc
@@ -33,3 +43,4 @@ test:
.PHONY: clean
clean:
$(MAKE) -C Documentation clean
+ $(RM) GUILT-VERSION-FILE guilt.bin
diff --git a/guilt b/guilt
index fabee17..7cfa23b 100755
--- a/guilt
+++ b/guilt
@@ -3,7 +3,9 @@
# Copyright (c) Josef "Jeff" Sipek, 2006-2008
#
-GUILT_VERSION="0.31.2"
+# Version replaced at build time. Could have in separate file, but why
+# do a "source version_file" on every guilt operation?
+GUILT_VERSION=
GUILT_NAME="Ciuleandra"
# If the first argument is one of the below, display the man page instead of
--
1.6.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] guilt: add git commit level versioning
2008-10-08 2:08 [PATCH] guilt: add git commit level versioning Paul Gortmaker
@ 2008-10-09 15:54 ` Josef 'Jeff' Sipek
2008-10-09 16:13 ` Paul Gortmaker
0 siblings, 1 reply; 3+ messages in thread
From: Josef 'Jeff' Sipek @ 2008-10-09 15:54 UTC (permalink / raw)
To: Paul Gortmaker; +Cc: git
On Tue, Oct 07, 2008 at 10:08:42PM -0400, Paul Gortmaker wrote:
> Shamelessly steal the dynamic versioning goodies from git
> itself. Now when you do "guilt --version" you can expect to
> see things like:
>
> Guilt version 0.31.2.14.gece1.dirty
>
> assuming you've 14 commits since 0.31.2 and also some changes
> that you've not committed yet.
Good idea. I've been pondering how to do this a while back, but never got
around to actually do it.
One comment: Why not keep the default version in guilt? You're running sed
on it anyway. This makes releasing identical to what it was before the
patch:
<edit guilt to reflect new version, commit>
git tag -u abcdef v0.xy
git archive --tar v0.xy | gzip -9 > guilt-0.xy.tar.gz
Additionally, things won't "break" for folks running right out of the git
repo - I just add the git repo dir to my $PATH.
Josef 'Jeff' Sipek.
--
Keyboard not found!
Press F1 to enter Setup
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] guilt: add git commit level versioning
2008-10-09 15:54 ` Josef 'Jeff' Sipek
@ 2008-10-09 16:13 ` Paul Gortmaker
0 siblings, 0 replies; 3+ messages in thread
From: Paul Gortmaker @ 2008-10-09 16:13 UTC (permalink / raw)
To: Josef 'Jeff' Sipek; +Cc: git
Josef 'Jeff' Sipek wrote:
> On Tue, Oct 07, 2008 at 10:08:42PM -0400, Paul Gortmaker wrote:
>
>> Shamelessly steal the dynamic versioning goodies from git
>> itself. Now when you do "guilt --version" you can expect to
>> see things like:
>>
>> Guilt version 0.31.2.14.gece1.dirty
>>
>> assuming you've 14 commits since 0.31.2 and also some changes
>> that you've not committed yet.
>>
>
> Good idea. I've been pondering how to do this a while back, but never got
> around to actually do it.
>
> One comment: Why not keep the default version in guilt? You're running sed
> on it anyway. This makes releasing identical to what it was before the
> patch:
> <edit guilt to reflect new version, commit>
> git tag -u abcdef v0.xy
> git archive --tar v0.xy | gzip -9 > guilt-0.xy.tar.gz
>
> Additionally, things won't "break" for folks running right out of the git
> repo - I just add the git repo dir to my $PATH.
>
Sounds reasonable to me. I'm about to disappear for a 4 day weekend
(Cdn Thanksgiving) so I won't be able to do that until next Tuesday at
the earliest though.
P.
> Josef 'Jeff' Sipek.
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-10-09 16:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-08 2:08 [PATCH] guilt: add git commit level versioning Paul Gortmaker
2008-10-09 15:54 ` Josef 'Jeff' Sipek
2008-10-09 16:13 ` Paul Gortmaker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).