bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gnulib-tool --version


From: Bruno Haible
Subject: Re: gnulib-tool --version
Date: Sun, 23 Mar 2008 12:25:39 +0100
User-agent: KMail/1.5.4

Eric Blake wrote:
> OK, I'm adding the latest ChangeLog date to the output (the GCS allows
> additional version information inside the parenthesis).
> 
> You still get UNKNOWN, but at least it now includes a date stamp.
> 
> $ gnulib-cvs/gnulib-tool --version
> gnulib-tool (GNU gnulib 2008-03-21) UNKNOWN

Not bad. But since we usually make several commits per day, it's still not
guaranteed to be unambiguous. Also, sometimes ChangeLog entries carry an
older date.

When CVS or git is available, this can be made more precise:

- In a git checkout:
  $ ./gnulib-tool --version
  gnulib-tool (GNU gnulib 2008-03-23 11:18:23) 0.0.381-6a23-dirty

- In a CVS checkout:
  $ ./gnulib-tool --version
  gnulib-tool (GNU gnulib 2008-03-23 12:18:23)

The difference of an integral number of hours is due to wrong timezone handling
in git-cvsserver; I've reported this as a bug separately.


2008-03-23  Bruno Haible  <address@hidden>

        Tweak "gnulib --version" output.
        * gnulib-tool (func_version): Use date of last commit to ChangeLog,
        rather than contents of ChangeLog, when possible.

*** gnulib-tool.orig    2008-03-23 12:16:53.000000000 +0100
--- gnulib-tool 2008-03-23 12:12:22.000000000 +0100
***************
*** 195,205 ****
  func_version ()
  {
    func_gnulib_dir
!   date=`sed 's/ .*//;q' "$gnulib_dir"/ChangeLog`
!   version=`"$gnulib_dir"/build-aux/git-version-gen /dev/null`
    year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed 's,^.* ,,'`
    echo "\
! gnulib-tool (GNU $package $date) $version
  Copyright (C) $year Free Software Foundation, Inc.
  License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
  This is free software: you are free to change and redistribute it.
--- 195,233 ----
  func_version ()
  {
    func_gnulib_dir
!   if test -d "$gnulib_dir"/.git \
!      && (git --version) >/dev/null 2>/dev/null \
!      && (date --version) >/dev/null 2>/dev/null; then
!     # gnulib checked out from git.
!     sed_extract_first_date='/^Date/{
! s/^Date:[      ]*//p
! q
! }'
!     date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e 
"$sed_extract_first_date"`
!     # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
!     sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) 
\([0-9]*\) /\1 \2 \4 \3 /'
!     date=`echo "$date" | sed -e "$sed_year_before_time"`
!     # Use GNU date to compute the time in GMT.
!     date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
!     version=' '`"$gnulib_dir"/build-aux/git-version-gen /dev/null`
!   else
!     if test -d "$gnulib_dir"/CVS \
!        && (cvs --version) >/dev/null 2>/dev/null; then
!       # gnulib checked out from CVS.
!       sed_extract_first_date='/^date: /{
! s/^date: \([0-9][0-9][0-9][0-9]\).\([0-9][0-9]\).\([0-9][0-9]\) 
\([0-9][0-9]:[0-9][0-9]:[0-9][0-9]\).*/\1-\2-\3 \4/p
! q
! }'
!       date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e 
"$sed_extract_first_date"`
!     else
!       # gnulib copy without versioning information.
!       date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
!     fi
!     version=
!   fi
    year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed 's,^.* ,,'`
    echo "\
! gnulib-tool (GNU $package $date)$version
  Copyright (C) $year Free Software Foundation, Inc.
  License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
  This is free software: you are free to change and redistribute it.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]