diff options
author | Eric Wong <e@80x24.org> | 2015-01-12 03:32:29 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-01-12 03:36:59 +0000 |
commit | 91c84b88292e16f06fb3f1ffe3b46f0ccd388323 (patch) | |
tree | a7497d63f4cd15ae3b3fb52719376aa6dcf2b375 | |
parent | a19b90096b800734502f1fb522d9a766fbaf7dc0 (diff) | |
download | kcar-91c84b88292e16f06fb3f1ffe3b46f0ccd388323.tar.gz |
It's probably useful to someone, so keep it to avoid needlessly breaking compatibility.
-rw-r--r-- | .gitignore | 1 | ||||
-rwxr-xr-x | GIT-VERSION-GEN | 60 | ||||
-rw-r--r-- | GNUmakefile | 2 | ||||
-rw-r--r-- | lib/kcar.rb | 7 |
4 files changed, 27 insertions, 43 deletions
@@ -14,6 +14,7 @@ pkg/ /NEWS* /.manifest /GIT-VERSION-FILE +/lib/kcar/version.rb /man tags TAGS diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index 4a466ed..dd9ca07 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -1,40 +1,28 @@ -#!/bin/sh - -GVF=GIT-VERSION-FILE -DEF_VER=v0.4.0.GIT - -LF=' -' +#!/usr/bin/env ruby +CONSTANT = "Kcar::VERSION" +RVF = "lib/kcar/version.rb" +DEF_VER = "v0.4.0" +vn = DEF_VER # 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 File.exist?(".git") + describe = `git describe --abbrev=4 HEAD 2>/dev/null`.strip + case describe + when /\Av[0-9]*/ + vn = describe + system(*%w(git update-index -q --refresh)) + unless `git diff-index --name-only HEAD --`.chomp.empty? + vn << "-dirty" + end + vn.tr!('-', '.') + end +end -if test -r $GVF -then - VC=$(sed -e 's/^GIT_VERSION = //' <$GVF) -else - VC=unset -fi -test "$VN" = "$VC" || { - echo >&2 "GIT_VERSION = $VN" - echo "GIT_VERSION = $VN" >$GVF -} +vn = vn.sub!(/\Av/, "") +new_ruby_version = "#{CONSTANT} = '#{vn}'\n" +cur_ruby_version = File.read(RVF) rescue nil +if new_ruby_version != cur_ruby_version + File.open(RVF, "w") { |fp| fp.write(new_ruby_version) } +end +puts vn if $0 == __FILE__ diff --git a/GNUmakefile b/GNUmakefile index 929eede..2fb0bd9 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -3,7 +3,7 @@ RSYNC_DEST := bogomips.org:/srv/bogomips/kcar RAGEL = ragel RLFLAGS = -G2 rfpackage := kcar -pkg_extra += ext/kcar/kcar.c +pkg_extra += ext/kcar/kcar.c lib/kcar/version.rb ext/kcar/kcar.c: ext/kcar/kcar.rl ext/kcar/kcar_http_common.rl cd $(@D) && $(RAGEL) kcar.rl -C $(RLFLAGS) -o $(@F) include pkg.mk diff --git a/lib/kcar.rb b/lib/kcar.rb index 1fe0554..55ac527 100644 --- a/lib/kcar.rb +++ b/lib/kcar.rb @@ -1,13 +1,8 @@ # -*- encoding: binary -*- module Kcar - - # current version of Kcar, currently 0.2.0 - # This constant is deprecated and will be removed in the next - # release. Use +respond_to?+ or +defined?+ instead to test for features. - VERSION = "0.2.0" - autoload :Response, 'kcar/response' end +require 'kcar/version' require 'kcar/parser' require 'kcar_ext' |