From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-2.9 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, URIBL_BLOCKED shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: kcar-public@bogomips.org Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 5A2C71FDF2 for ; Mon, 12 Jan 2015 07:43:05 +0000 (UTC) From: Eric Wong To: kcar-public@bogomips.org Subject: [PATCH] continue generating VERSION constant Date: Mon, 12 Jan 2015 07:43:04 +0000 Message-Id: <1421048584-16553-3-git-send-email-e@80x24.org> X-Mailer: git-send-email 2.2.1.271.g3978422.dirty List-Id: It's probably useful to someone, so keep it to avoid needlessly breaking compatibility. --- .gitignore | 1 + GIT-VERSION-GEN | 60 +++++++++++++++++++++++---------------------------------- GNUmakefile | 2 +- lib/kcar.rb | 7 +------ 4 files changed, 27 insertions(+), 43 deletions(-) diff --git a/.gitignore b/.gitignore index a6c49b4..4495968 100644 --- a/.gitignore +++ b/.gitignore @@ -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' -- EW