+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.
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/'`
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