]> Savannah Git Hosting - gnulib.git/commitdiff
gnulib-tool: Make --version output independent of git's configuration.
authorBruno Haible <bruno@clisp.org>
Wed, 28 Feb 2024 10:52:33 +0000 (11:52 +0100)
committerBruno Haible <bruno@clisp.org>
Wed, 28 Feb 2024 10:52:33 +0000 (11:52 +0100)
Reported by Collin Funk <collin.funk1@gmail.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2024-02/msg00268.html>.

* pygnulib/GLInfo.py (GLInfo.date): Pass --format and --date options, to
override the user's git configuration.
* gnulib-tool (func_version): Likewise. Also pass options '-n 1', to
speed up the operation.

ChangeLog
gnulib-tool
pygnulib/GLInfo.py

index e667861d9cc766410a724ec29ecff97e11a904d9..330727e02e2d2b1f258f784d3238b78b1a562cde 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-02-28  Bruno Haible  <bruno@clisp.org>
+
+       gnulib-tool: Make --version output independent of git's configuration.
+       Reported by Collin Funk <collin.funk1@gmail.com> in
+       <https://lists.gnu.org/archive/html/bug-gnulib/2024-02/msg00268.html>.
+       * pygnulib/GLInfo.py (GLInfo.date): Pass --format and --date options, to
+       override the user's git configuration.
+       * gnulib-tool (func_version): Likewise. Also pass options '-n 1', to
+       speed up the operation.
+
 2024-02-28  Bruno Haible  <bruno@clisp.org>
 
        gnulib-tool.py: Avoid exception when 'git log' output is unexpected.
index 2e10abcfccf39dac7daae2378412b9920b441314..a7ba7a98f1ca5ef0e4723178e75cb414cf256552 100755 (executable)
@@ -359,10 +359,7 @@ func_version ()
 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"`
+    date=`cd "$gnulib_dir" && git log -n 1 --format=medium --date=iso ChangeLog | sed -n -e "$sed_extract_first_date"`
     # Use GNU date to compute the time in GMT.
     date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
     version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
index 8ffe1d309bc5899942d1d6f82b0c87afb93dc65d..a0a70270a926718bda381f4e1c58f9825b3e582e 100644 (file)
@@ -102,16 +102,13 @@ class GLInfo(object):
                 except:
                     have_GNU_date = False
                 if have_GNU_date:
-                    args = ['git', 'log', '-n', '1', 'ChangeLog']
+                    args = ['git', 'log', '-n', '1', '--format=medium', '--date=iso', 'ChangeLog']
                     result = sp.check_output(args, cwd=DIRS['root']).decode("UTF-8")
-                    # Get date as "Fri Mar 21 07:16:51 2008 -0600" from string
+                    # Get date as "2008-03-21 07:16:51 -0600" from string
                     pattern = re.compile('^Date:[\t ]*(.*?)$', re.M)
                     result = pattern.findall(result)
                     if (len(result) > 0):
                         result = result[0]
-                        # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600"
-                        pattern = re.compile('^[^ ]* ([^ ]*) ([0-9]*) ([0-9:]*) ([0-9]*) ')
-                        result = pattern.sub('\\1 \\2 \\4 \\3 ', result)
                     else:
                         result = ''
                     # Use GNU date to compute the time in GMT