{"thread":{"id":"15820","subject":"[PATCH] guilt: add git commit level versioning","startedAt":"2008-10-08T02:08:42Z","lastAt":"2008-10-09T16:13:14Z","messageCount":3,"participants":["Paul Gortmaker","Josef 'Jeff' Sipek"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"92576","messageId":"1223431722-12259-1-git-send-email-paul.gortmaker@windriver.com","threadId":"15820","inReplyTo":null,"subject":"[PATCH] guilt: add git commit level versioning","fromName":"Paul Gortmaker","fromEmail":"paul.gortmaker@windriver.com","sentAt":"2008-10-08T02:08:42Z","receivedAt":"2008-10-08T02:08:42Z","isPatch":true,"sender":{"key":"paul.gortmaker@windriver.com","avatar":null},"body":"Shamelessly steal the dynamic versioning goodies from git\nitself.  Now when you do \"guilt --version\" you can expect to\nsee things like:\n\n\tGuilt version 0.31.2.14.gece1.dirty\n\nassuming you've 14 commits since 0.31.2 and also some changes\nthat you've not committed yet.\n\nSigned-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>\n---\n .gitignore             |    2 ++\n Documentation/Makefile |    4 ++--\n GUILT-VERSION-GEN      |   42 ++++++++++++++++++++++++++++++++++++++++++\n Makefile               |   21 ++++++++++++++++-----\n guilt                  |    4 +++-\n 5 files changed, 65 insertions(+), 8 deletions(-)\n create mode 100755 GUILT-VERSION-GEN\n\ndiff --git a/.gitignore b/.gitignore\nindex c81112b..61161ef 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -7,3 +7,5 @@\n #\n *~\n *.swp\n+guilt.bin\n+GUILT-VERSION-FILE\ndiff --git a/Documentation/Makefile b/Documentation/Makefile\nindex 9fc1165..4b7d037 100644\n--- a/Documentation/Makefile\n+++ b/Documentation/Makefile\n@@ -7,7 +7,7 @@ DOC_MAN1=$(patsubst %.txt,%.1,$(MAN1_TXT))\n DOC_MAN7=$(patsubst %.txt,%.7,$(MAN7_TXT))\n \n USAGE=$(patsubst %.txt,usage-%.txt,$(MAN1_TXT))\n-VERSION=$(shell git describe 2> /dev/null || sed -n -e '/^GUILT_VERSION=/ { s/^GUILT_VERSION=\"/v/; s/\"//; p; q; }' ../guilt)\n+include ../GUILT-VERSION-FILE\n \n prefix?=$(PREFIX)\n bindir?=$(prefix)/bin\n@@ -51,7 +51,7 @@ doc.dep : $(wildcard *.txt) build-docdep.perl\n -include doc.dep\n \n version.txt:\n-\techo \"(Generated for Guilt $(VERSION))\" > version.txt\n+\techo \"(Generated for Guilt $(GUILT_VERSION))\" > version.txt\n \n cmds.txt: cmd-list.sh $(MAN1_TXT)\n \tsh ./cmd-list.sh\ndiff --git a/GUILT-VERSION-GEN b/GUILT-VERSION-GEN\nnew file mode 100755\nindex 0000000..66b40e2\n--- /dev/null\n+++ b/GUILT-VERSION-GEN\n@@ -0,0 +1,42 @@\n+#!/bin/sh\n+\n+GVF=GUILT-VERSION-FILE\n+DEF_VER=v0.31.2\n+\n+LF='\n+'\n+\n+# First see if there is a version file (included in release tarballs),\n+# then try git-describe, then default.\n+if test -f version\n+then\n+\tVN=$(cat version) || VN=\"$DEF_VER\"\n+elif test -d .git -o -f .git &&\n+\tVN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&\n+\tcase \"$VN\" in\n+\t*$LF*) (exit 1) ;;\n+\tv[0-9]*)\n+\t\tgit update-index -q --refresh\n+\t\ttest -z \"$(git diff-index --name-only HEAD --)\" ||\n+\t\tVN=\"$VN-dirty\" ;;\n+\tesac\n+then\n+\tVN=$(echo \"$VN\" | sed -e 's/-/./g');\n+else\n+\tVN=\"$DEF_VER\"\n+fi\n+\n+VN=$(expr \"$VN\" : v*'\\(.*\\)')\n+\n+if test -r $GVF\n+then\n+\tVC=$(sed -e 's/^GUILT_VERSION = //' <$GVF)\n+else\n+\tVC=unset\n+fi\n+test \"$VN\" = \"$VC\" || {\n+\techo >&2 \"GUILT_VERSION=$VN\"\n+\techo \"GUILT_VERSION=$VN\" >$GVF\n+}\n+\n+\ndiff --git a/Makefile b/Makefile\nindex af53fb5..f3cf0b3 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1,25 +1,35 @@\n PREFIX=/usr/local\n DESTDIR=\n \n-SCRIPTS = guilt \\\n-\t  $(filter-out $(wildcard *~),$(wildcard guilt-*))\n+SCRIPTS = $(filter-out $(wildcard *~),$(wildcard guilt-*))\n \n-.PHONY: all \n-all: doc\n+all::\n+\n+.PHONY: .FORCE-GUILT-VERSION-FILE\n+GUILT-VERSION-FILE: .FORCE-GUILT-VERSION-FILE\n+\t@$(SHELL_PATH) ./GUILT-VERSION-GEN\n+-include GUILT-VERSION-FILE\n+\n+.PHONY: all\n+all:: doc guilt.bin\n \t@echo \"Nothing to build, it is all bash :)\"\n \t@echo \"Try make install\"\n \n+guilt.bin: GUILT-VERSION-FILE\n+\t@sed 's/^GUILT_VERSION=$$/GUILT_VERSION=\"$(GUILT_VERSION)\"/' < guilt > guilt.bin\n+\n .PHONY: install\n install:\n \tinstall -d $(DESTDIR)$(PREFIX)/bin/\n \tinstall -m 755 $(SCRIPTS) $(DESTDIR)$(PREFIX)/bin/\n+\tinstall -m 755 guilt.bin $(DESTDIR)$(PREFIX)/bin/guilt\n \n .PHONY: uninstall\n uninstall:\n \t./uninstall $(DESTDIR)$(PREFIX)/bin/ $(SCRIPTS)\n \n .PHONY: doc\n-doc:\n+doc: GUILT-VERSION-FILE\n \t$(MAKE) -C Documentation all\n \n .PHONY: install-doc\n@@ -33,3 +43,4 @@ test:\n .PHONY: clean\n clean: \n \t$(MAKE) -C Documentation clean \n+\t$(RM) GUILT-VERSION-FILE guilt.bin\ndiff --git a/guilt b/guilt\nindex fabee17..7cfa23b 100755\n--- a/guilt\n+++ b/guilt\n@@ -3,7 +3,9 @@\n # Copyright (c) Josef \"Jeff\" Sipek, 2006-2008\n #\n \n-GUILT_VERSION=\"0.31.2\"\n+# Version replaced at build time. Could have in separate file, but why\n+# do a \"source version_file\" on every guilt operation?\n+GUILT_VERSION=\n GUILT_NAME=\"Ciuleandra\"\n \n # If the first argument is one of the below, display the man page instead of\n-- \n1.6.0\n"},{"id":"92684","messageId":"20081009155445.GF27647@josefsipek.net","threadId":"15820","inReplyTo":"1223431722-12259-1-git-send-email-paul.gortmaker@windriver.com","subject":"Re: [PATCH] guilt: add git commit level versioning","fromName":"Josef 'Jeff' Sipek","fromEmail":"jeffpc@josefsipek.net","sentAt":"2008-10-09T15:54:45Z","receivedAt":"2008-10-09T15:54:45Z","isPatch":true,"sender":{"key":"jeffpc@josefsipek.net","avatar":null},"body":"On Tue, Oct 07, 2008 at 10:08:42PM -0400, Paul Gortmaker wrote:\n> Shamelessly steal the dynamic versioning goodies from git\n> itself.  Now when you do \"guilt --version\" you can expect to\n> see things like:\n> \n> \tGuilt version 0.31.2.14.gece1.dirty\n> \n> assuming you've 14 commits since 0.31.2 and also some changes\n> that you've not committed yet.\n\nGood idea. I've been pondering how to do this a while back, but never got\naround to actually do it.\n\nOne comment: Why not keep the default version in guilt? You're running sed\non it anyway.  This makes releasing identical to what it was before the\npatch:\n\t<edit guilt to reflect new version, commit>\n\tgit tag -u abcdef v0.xy\n\tgit archive --tar v0.xy | gzip -9 > guilt-0.xy.tar.gz\n\nAdditionally, things won't \"break\" for folks running right out of the git\nrepo - I just add the git repo dir to my $PATH.\n\nJosef 'Jeff' Sipek.\n\n-- \nKeyboard not found!\nPress F1 to enter Setup\n"},{"id":"92688","messageId":"48EE2D9A.20205@windriver.com","threadId":"15820","inReplyTo":"20081009155445.GF27647@josefsipek.net","subject":"Re: [PATCH] guilt: add git commit level versioning","fromName":"Paul Gortmaker","fromEmail":"paul.gortmaker@windriver.com","sentAt":"2008-10-09T16:13:14Z","receivedAt":"2008-10-09T16:13:14Z","isPatch":true,"sender":{"key":"paul.gortmaker@windriver.com","avatar":null},"body":"Josef 'Jeff' Sipek wrote:\n> On Tue, Oct 07, 2008 at 10:08:42PM -0400, Paul Gortmaker wrote:\n>   \n>> Shamelessly steal the dynamic versioning goodies from git\n>> itself.  Now when you do \"guilt --version\" you can expect to\n>> see things like:\n>>\n>> \tGuilt version 0.31.2.14.gece1.dirty\n>>\n>> assuming you've 14 commits since 0.31.2 and also some changes\n>> that you've not committed yet.\n>>     \n>\n> Good idea. I've been pondering how to do this a while back, but never got\n> around to actually do it.\n>\n> One comment: Why not keep the default version in guilt? You're running sed\n> on it anyway.  This makes releasing identical to what it was before the\n> patch:\n> \t<edit guilt to reflect new version, commit>\n> \tgit tag -u abcdef v0.xy\n> \tgit archive --tar v0.xy | gzip -9 > guilt-0.xy.tar.gz\n>\n> Additionally, things won't \"break\" for folks running right out of the git\n> repo - I just add the git repo dir to my $PATH.\n>   \n\nSounds reasonable to me.  I'm about to disappear for a 4 day weekend\n(Cdn Thanksgiving) so I won't be able to do that until next Tuesday at\nthe earliest though.\n\nP.\n\n> Josef 'Jeff' Sipek.\n>\n>   \n"}]}