* Can we have gnulib-tool.py emit the same copyright header?
@ 2024-02-28 1:41 Collin Funk
2024-02-28 2:07 ` Bruno Haible
0 siblings, 1 reply; 11+ messages in thread
From: Collin Funk @ 2024-02-28 1:41 UTC (permalink / raw)
To: bug-gnulib
[-- Attachment #1: Type: text/plain, Size: 1318 bytes --]
When creating a Makefile for example, the diff between gnulib-tool and
gnulib-tool.py is:
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
index a718c17c0e8..15d15970051 100644
--- a/lib/gnulib.mk.in
+++ b/lib/gnulib.mk.in
@@ -1,5 +1,5 @@
## DO NOT EDIT! GENERATED AUTOMATICALLY!
-# Copyright (C) 2002-2024 Free Software Foundation, Inc.
+# Copyright (C) 2024 Free Software Foundation, Inc.
The gnulib-tool.py one only does a single year instead of the range.
This diff is copied from the attached patch:
diff --git a/pygnulib/GLInfo.py b/pygnulib/GLInfo.py
index 808f11b06f..1759368268 100644
--- a/pygnulib/GLInfo.py
+++ b/pygnulib/GLInfo.py
@@ -80,8 +80,6 @@ class GLInfo(object):
'''Return formatted string which contains copyright.
The special __copyright__ variable is used (type is str).'''
copyright = __copyright__
- # Per the GNU Coding Standards, show only the last year.
- copyright = re.compile('^[0-9]*-').sub('', copyright)
result = 'Copyright (C) %s' % copyright
return result
The GNU Maintainer guide seems to disagree with this comment (assuming
that gnulib-tool.py is not a separate package) [1]. Am I missing
something or can we make this change?
[1] https://www.gnu.org/prep/maintain/maintain.html#Copyright-Notices
Thanks,
Collin
[-- Attachment #2: 0001-gnulib-tool.py-Emit-copyright-notices-as-a-year-rang.patch --]
[-- Type: text/x-patch, Size: 1441 bytes --]
From 202d152d8a0a6fa3875c44ff5cd38bdd4b0d485d Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.funk1@gmail.com>
Date: Tue, 27 Feb 2024 17:30:18 -0800
Subject: [PATCH] gnulib-tool.py: Emit copyright notices as a year range.
* pygnulib/GLInfo.py (GLInfo.copyright): Fix copyright string. Remove
comment to reflect change.
---
ChangeLog | 6 ++++++
pygnulib/GLInfo.py | 2 --
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index af3af3707e..84f5bcee88 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-02-27 Collin Funk <collin.funk1@gmail.com>
+
+ gnulib-tool.py: Emit copyright notices as a year range.
+ * pygnulib/GLInfo.py (GLInfo.copyright): Fix copyright string. Remove
+ comment to reflect change.
+
2024-02-27 Bruno Haible <bruno@clisp.org>
isnan: Fix compilation error in C++ mode on OpenBSD 7.5-beta.
diff --git a/pygnulib/GLInfo.py b/pygnulib/GLInfo.py
index 808f11b06f..1759368268 100644
--- a/pygnulib/GLInfo.py
+++ b/pygnulib/GLInfo.py
@@ -80,8 +80,6 @@ class GLInfo(object):
'''Return formatted string which contains copyright.
The special __copyright__ variable is used (type is str).'''
copyright = __copyright__
- # Per the GNU Coding Standards, show only the last year.
- copyright = re.compile('^[0-9]*-').sub('', copyright)
result = 'Copyright (C) %s' % copyright
return result
--
2.39.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: Can we have gnulib-tool.py emit the same copyright header?
2024-02-28 1:41 Can we have gnulib-tool.py emit the same copyright header? Collin Funk
@ 2024-02-28 2:07 ` Bruno Haible
2024-02-28 2:19 ` Collin Funk
0 siblings, 1 reply; 11+ messages in thread
From: Bruno Haible @ 2024-02-28 2:07 UTC (permalink / raw)
To: bug-gnulib; +Cc: Collin Funk
Hi Collin,
> When creating a Makefile for example, the diff between gnulib-tool and
> gnulib-tool.py is:
>
> diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
> index a718c17c0e8..15d15970051 100644
> --- a/lib/gnulib.mk.in
> +++ b/lib/gnulib.mk.in
> @@ -1,5 +1,5 @@
> ## DO NOT EDIT! GENERATED AUTOMATICALLY!
> -# Copyright (C) 2002-2024 Free Software Foundation, Inc.
> +# Copyright (C) 2024 Free Software Foundation, Inc.
>
> The gnulib-tool.py one only does a single year instead of the range.
>
> This diff is copied from the attached patch:
>
> diff --git a/pygnulib/GLInfo.py b/pygnulib/GLInfo.py
> index 808f11b06f..1759368268 100644
> --- a/pygnulib/GLInfo.py
> +++ b/pygnulib/GLInfo.py
> @@ -80,8 +80,6 @@ class GLInfo(object):
> '''Return formatted string which contains copyright.
> The special __copyright__ variable is used (type is str).'''
> copyright = __copyright__
> - # Per the GNU Coding Standards, show only the last year.
> - copyright = re.compile('^[0-9]*-').sub('', copyright)
> result = 'Copyright (C) %s' % copyright
> return result
When I wrote this piece of code (2022-08-05), it was for the --version
output. I had apparently overlooked that the method GLInfo.copyright
also gets used in other contexts than for processing the --version
option.
> The GNU Maintainer guide seems to disagree with this comment (assuming
> that gnulib-tool.py is not a separate package) [1]. Am I missing
> something or can we make this change?
>
> [1] https://www.gnu.org/prep/maintain/maintain.html#Copyright-Notices
In *files*, the copyright notice should contain the first and the last year
of modification; a range <first>-<last> is OK. [1]
In *--version output*, the copyright notice should contain only the last year.
[2]
Bruno
[1] https://www.gnu.org/prep/maintain/html_node/Copyright-Notices.html
[2] https://www.gnu.org/prep/standards/html_node/_002d_002dversion.html
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Can we have gnulib-tool.py emit the same copyright header?
2024-02-28 2:07 ` Bruno Haible
@ 2024-02-28 2:19 ` Collin Funk
2024-02-28 2:26 ` Bruno Haible
0 siblings, 1 reply; 11+ messages in thread
From: Collin Funk @ 2024-02-28 2:19 UTC (permalink / raw)
To: Bruno Haible, bug-gnulib
On 2/27/24 6:07 PM, Bruno Haible wrote:
> When I wrote this piece of code (2022-08-05), it was for the --version
> output. I had apparently overlooked that the method GLInfo.copyright
> also gets used in other contexts than for processing the --version
> option.
Ah I see. I probably should have grep'd for that function because I
didn't notice it was used there.
> In *files*, the copyright notice should contain the first and the last year
> of modification; a range <first>-<last> is OK. [1]
>
> In *--version output*, the copyright notice should contain only the last year.
> [2]
That makes sense, thanks. I tried to run --version and got this:
[collin@debian gnulib]$ gnulib-tool.py --version
Traceback (most recent call last):
File "/home/collin/.local/src/gnulib/pygnulib/main.py", line 1197, in <module>
main()
File "/home/collin/.local/src/gnulib/pygnulib/main.py", line 442, in main
% (info.package(), info.date(), version, info.copyright(),
^^^^^^^^^^^
File "/home/collin/.local/src/gnulib/pygnulib/GLInfo.py", line 109, in date
result = pattern.findall(result)[0]
~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range
So, I'll have a look at that fixing that. :)
Collin
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Can we have gnulib-tool.py emit the same copyright header?
2024-02-28 2:19 ` Collin Funk
@ 2024-02-28 2:26 ` Bruno Haible
2024-02-28 2:51 ` Collin Funk
0 siblings, 1 reply; 11+ messages in thread
From: Bruno Haible @ 2024-02-28 2:26 UTC (permalink / raw)
To: bug-gnulib, Collin Funk
Collin Funk wrote:
> I tried to run --version and got this:
>
> [collin@debian gnulib]$ gnulib-tool.py --version
> Traceback (most recent call last):
> File "/home/collin/.local/src/gnulib/pygnulib/main.py", line 1197, in <module>
> main()
> File "/home/collin/.local/src/gnulib/pygnulib/main.py", line 442, in main
> % (info.package(), info.date(), version, info.copyright(),
> ^^^^^^^^^^^
> File "/home/collin/.local/src/gnulib/pygnulib/GLInfo.py", line 109, in date
> result = pattern.findall(result)[0]
> ~~~~~~~~~~~~~~~~~~~~~~~^^^
> IndexError: list index out of range
Huh? For me, it works fine:
$ ./gnulib-tool.py --version
gnulib-tool (GNU gnulib 2024-02-27 23:33:49) 0.1.7153-431d6
Copyright (C) 2024 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Bruno Haible, Paul Eggert, Simon Josefsson, and Dmitry Selyutin.
$ python3 --version
Python 3.10.12
$ git --version
git version 2.34.1
$ git log -n 1 ChangeLog | grep ^Date:
Date: Wed Feb 28 00:33:49 2024 +0100
Bruno
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Can we have gnulib-tool.py emit the same copyright header?
2024-02-28 2:26 ` Bruno Haible
@ 2024-02-28 2:51 ` Collin Funk
2024-02-28 7:53 ` Collin Funk
0 siblings, 1 reply; 11+ messages in thread
From: Collin Funk @ 2024-02-28 2:51 UTC (permalink / raw)
To: Bruno Haible, bug-gnulib
On 2/27/24 6:26 PM, Bruno Haible wrote:
> git log -n 1 ChangeLog | grep ^Date:
Ah, I see what is happening.
[collin@debian gnulib]$ git log -n 1
commit 431d6a7615245e6b32d95b4b27aab5d3af65ad2b (HEAD -> master, origin/master, origin/HEAD)
Author: Bruno Haible <bruno@clisp.org>
AuthorDate: Wed Feb 28 00:33:49 2024 +0100
Commit: Bruno Haible <bruno@clisp.org>
CommitDate: Wed Feb 28 00:33:49 2024 +0100
isnan: Fix compilation error in C++ mode on OpenBSD 7.5-beta.
Reported by Christian Weisgerber <naddy@mips.inka.de> in
<https://lists.gnu.org/archive/html/bug-gnulib/2024-02/msg00261.html>.
* lib/math.in.h (GNULIB_NAMESPACE_LACKS_ISNAN): Define on all platforms
with clang ≥ 14.
So the grep ^Date fails. I don't remember changing this but in my git
config it is caused by this [1]:
[format]
pretty = fuller
The regular gnulib-tool gives me this:
[collin@debian gnulib]$ gnulib-tool --version
gnulib-tool (GNU gnulib 2024-02-28 00:00:00) 0.1.7153-431d6
Copyright (C) 2024 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Bruno Haible, Paul Eggert, and Simon Josefsson.
It seems that some people might have their git log settings so that
there isn't even a date or name:
[collin@debian gnulib]$ git log --pretty=oneline
431d6a7615245e6b32d95b4b27aab5d3af65ad2b (HEAD -> master, origin/master, origin/HEAD) isnan: Fix compilation error in C++ mode on OpenBSD 7.5-beta.
38a9bb6e0ae3f5c71da8eb5db5ea7aa41b14f3e4 gnulib-tool.py: Fix configure.ac output.
e1f51c8e0431fe2598479daf76690e1d4d7c1a88 gnulib-tool.py: Follow gnulib-tool changes, part 31.
bb09847b7d87d1c99a29f889372bc4771eb9d2bd gnulib-tool.py: Small fix of part 27.
I wonder which version this feature was added... I'm not sure how git
will act with invalid arguments but ideally we could run something
like:
[collin@debian gnulib]$ git log --pretty=medium -n 1 | grep '^Date:'
Date: Wed Feb 28 00:33:49 2024 +0100
I think medium looks like the default, but I'd have to double check.
[1] https://git-scm.com/docs/pretty-formats
Collin
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Can we have gnulib-tool.py emit the same copyright header?
2024-02-28 2:51 ` Collin Funk
@ 2024-02-28 7:53 ` Collin Funk
2024-02-28 11:00 ` Bruno Haible
0 siblings, 1 reply; 11+ messages in thread
From: Collin Funk @ 2024-02-28 7:53 UTC (permalink / raw)
To: Bruno Haible, bug-gnulib
On 2/27/24 6:51 PM, Collin Funk wrote:
> [collin@debian gnulib]$ git log --pretty=medium -n 1 | grep '^Date:'
It seems that the 'git command-name --pretty=medium' existed before
git version 1. I've found the commit that introduced the version I was
using that caused breakage [1]. It seems that my git config also
breaks a test case in vc-dwim. I've just changed my config for now,
but assuming that command doesn't have any problems I can submit a fix
there.
[2] https://github.com/git/git/commit/ff56fe1ca7f43087fd84588af87179c2959d0cb3
Collin
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Can we have gnulib-tool.py emit the same copyright header?
2024-02-28 7:53 ` Collin Funk
@ 2024-02-28 11:00 ` Bruno Haible
2024-02-28 21:18 ` Collin Funk
0 siblings, 1 reply; 11+ messages in thread
From: Bruno Haible @ 2024-02-28 11:00 UTC (permalink / raw)
To: bug-gnulib, Collin Funk
[-- Attachment #1: Type: text/plain, Size: 2645 bytes --]
Collin Funk wrote:
> > git log -n 1 ChangeLog | grep ^Date:
>
> Ah, I see what is happening.
>
> [collin@debian gnulib]$ git log -n 1
> commit 431d6a7615245e6b32d95b4b27aab5d3af65ad2b (HEAD -> master, origin/master, origin/HEAD)
> Author: Bruno Haible <bruno@clisp.org>
> AuthorDate: Wed Feb 28 00:33:49 2024 +0100
> Commit: Bruno Haible <bruno@clisp.org>
> CommitDate: Wed Feb 28 00:33:49 2024 +0100
>
> isnan: Fix compilation error in C++ mode on OpenBSD 7.5-beta.
>
> Reported by Christian Weisgerber <naddy@mips.inka.de> in
> <https://lists.gnu.org/archive/html/bug-gnulib/2024-02/msg00261.html>.
>
> * lib/math.in.h (GNULIB_NAMESPACE_LACKS_ISNAN): Define on all platforms
> with clang ≥ 14.
>
> So the grep ^Date fails. I don't remember changing this but in my git
> config it is caused by this [1]:
>
> [format]
> pretty = fuller
OK, so we need to make this piece of code more robust against various
git configurations.
> The regular gnulib-tool gives me this:
>
> [collin@debian gnulib]$ gnulib-tool --version
> gnulib-tool (GNU gnulib 2024-02-28 00:00:00) 0.1.7153-431d6
Here, the git configuration fooled gnulib-tool too. $date ended up
being empty, and GNU date interprets the empty strings as "today at 00:00:00".
Which was unintended, but it's a decent fallback behaviour worth porting to
the Python code.
> It seems that the 'git command-name --pretty=medium' existed before
> git version 1.
Good. Thanks for the investigation.
I'm committing these three patches, that fix the version output also in the
presence of
[log]
date = relative
[format]
pretty = fuller
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.
* pygnulib/GLInfo.py (GLInfo.date): When the 'git log' output does not
contain a line with the expected 'Date:' pattern, pass the empty string
to GNU date.
2024-02-28 Bruno Haible <bruno@clisp.org>
gnulib-tool: Avoid references to functions that get defined later.
* gnulib-tool (func_fatal_error, func_warning, func_readlink): Move
before func_gnulib_dir.
[-- Attachment #2: 0001-gnulib-tool-Avoid-references-to-functions-that-get-d.patch --]
[-- Type: text/x-patch, Size: 3142 bytes --]
From 584ef464a310638f94a79e9b4710fde41c884e7d Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Wed, 28 Feb 2024 11:23:17 +0100
Subject: [PATCH 1/3] gnulib-tool: Avoid references to functions that get
defined later.
* gnulib-tool (func_fatal_error, func_warning, func_readlink): Move
before func_gnulib_dir.
---
ChangeLog | 6 +++++
gnulib-tool | 70 ++++++++++++++++++++++++++---------------------------
2 files changed, 41 insertions(+), 35 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index af3af3707e..af0835269f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-02-28 Bruno Haible <bruno@clisp.org>
+
+ gnulib-tool: Avoid references to functions that get defined later.
+ * gnulib-tool (func_fatal_error, func_warning, func_readlink): Move
+ before func_gnulib_dir.
+
2024-02-27 Bruno Haible <bruno@clisp.org>
isnan: Fix compilation error in C++ mode on OpenBSD 7.5-beta.
diff --git a/gnulib-tool b/gnulib-tool
index 029a8cf377..2e10abcfcc 100755
--- a/gnulib-tool
+++ b/gnulib-tool
@@ -421,6 +421,41 @@ func_exit ()
(exit $1); exit $1
}
+# func_fatal_error message
+# outputs to stderr a fatal error message, and terminates the program.
+# Input:
+# - progname name of this program
+func_fatal_error ()
+{
+ echo "$progname: *** $1" 1>&2
+ echo "$progname: *** Stop." 1>&2
+ func_exit 1
+}
+
+# func_warning message
+# Outputs to stderr a warning message,
+func_warning ()
+{
+ echo "gnulib-tool: warning: $1" 1>&2
+}
+
+# func_readlink SYMLINK
+# outputs the target of the given symlink.
+if (type readlink) > /dev/null 2>&1; then
+ func_readlink ()
+ {
+ # Use the readlink program from GNU coreutils.
+ readlink "$1"
+ }
+else
+ func_readlink ()
+ {
+ # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
+ # would do the wrong thing if the link target contains " -> ".
+ LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
+ }
+fi
+
# func_gnulib_dir
# locates the directory where the gnulib repository lives
# Input:
@@ -672,41 +707,6 @@ else
fast_func_remove_suffix=false
fi
-# func_fatal_error message
-# outputs to stderr a fatal error message, and terminates the program.
-# Input:
-# - progname name of this program
-func_fatal_error ()
-{
- echo "$progname: *** $1" 1>&2
- echo "$progname: *** Stop." 1>&2
- func_exit 1
-}
-
-# func_warning message
-# Outputs to stderr a warning message,
-func_warning ()
-{
- echo "gnulib-tool: warning: $1" 1>&2
-}
-
-# func_readlink SYMLINK
-# outputs the target of the given symlink.
-if (type readlink) > /dev/null 2>&1; then
- func_readlink ()
- {
- # Use the readlink program from GNU coreutils.
- readlink "$1"
- }
-else
- func_readlink ()
- {
- # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
- # would do the wrong thing if the link target contains " -> ".
- LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
- }
-fi
-
# func_relativize DIR1 DIR2
# computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
# Input:
--
2.34.1
[-- Attachment #3: 0002-gnulib-tool.py-Avoid-exception-when-git-log-output-i.patch --]
[-- Type: text/x-patch, Size: 2444 bytes --]
From 0127a5e68be69a8c57bb43171bae3b1bb7ae4a6e Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Wed, 28 Feb 2024 11:38:00 +0100
Subject: [PATCH 2/3] gnulib-tool.py: Avoid exception when 'git log' output is
unexpected.
* pygnulib/GLInfo.py (GLInfo.date): When the 'git log' output does not
contain a line with the expected 'Date:' pattern, pass the empty string
to GNU date.
---
ChangeLog | 7 +++++++
pygnulib/GLInfo.py | 12 ++++++++----
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index af0835269f..e667861d9c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-02-28 Bruno Haible <bruno@clisp.org>
+
+ gnulib-tool.py: Avoid exception when 'git log' output is unexpected.
+ * pygnulib/GLInfo.py (GLInfo.date): When the 'git log' output does not
+ contain a line with the expected 'Date:' pattern, pass the empty string
+ to GNU date.
+
2024-02-28 Bruno Haible <bruno@clisp.org>
gnulib-tool: Avoid references to functions that get defined later.
diff --git a/pygnulib/GLInfo.py b/pygnulib/GLInfo.py
index 808f11b06f..8ffe1d309b 100644
--- a/pygnulib/GLInfo.py
+++ b/pygnulib/GLInfo.py
@@ -106,10 +106,14 @@ class GLInfo(object):
result = sp.check_output(args, cwd=DIRS['root']).decode("UTF-8")
# Get date as "Fri Mar 21 07:16:51 2008 -0600" from string
pattern = re.compile('^Date:[\t ]*(.*?)$', re.M)
- result = pattern.findall(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)
+ 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
args = ['date', '-d', result, '-u', '+%Y-%m-%d %H:%M:%S']
proc = sp.check_output(args)
--
2.34.1
[-- Attachment #4: 0003-gnulib-tool-Make-version-output-independent-of-git-s.patch --]
[-- Type: text/x-patch, Size: 3557 bytes --]
From 6231494948ccc053b4b71be412e193ff33cfb16c Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Wed, 28 Feb 2024 11:52:33 +0100
Subject: [PATCH 3/3] 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.
---
ChangeLog | 10 ++++++++++
gnulib-tool | 5 +----
pygnulib/GLInfo.py | 7 ++-----
3 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e667861d9c..330727e02e 100644
--- 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.
diff --git a/gnulib-tool b/gnulib-tool
index 2e10abcfcc..a7ba7a98f1 100755
--- a/gnulib-tool
+++ b/gnulib-tool
@@ -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/'`
diff --git a/pygnulib/GLInfo.py b/pygnulib/GLInfo.py
index 8ffe1d309b..a0a70270a9 100644
--- a/pygnulib/GLInfo.py
+++ b/pygnulib/GLInfo.py
@@ -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
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: Can we have gnulib-tool.py emit the same copyright header?
2024-02-28 11:00 ` Bruno Haible
@ 2024-02-28 21:18 ` Collin Funk
2024-02-28 21:30 ` Bruno Haible
0 siblings, 1 reply; 11+ messages in thread
From: Collin Funk @ 2024-02-28 21:18 UTC (permalink / raw)
To: Bruno Haible, bug-gnulib
[-- Attachment #1: Type: text/plain, Size: 463 bytes --]
On 2/28/24 3:00 AM, Bruno Haible wrote:
> I'm committing these three patches, that fix the version output also in the
> presence of
>
> [log]
> date = relative
Nice. I wasn't aware of this option. Your fixes give me the correct
date and time now.
How does this patch look for fixing the copyright headers? I could
have just used constants.__copyright__ in GLEmiter, but I thought it
was best to put in GLInfo just in case it is needed elsewhere later.
Collin
[-- Attachment #2: 0001-gnulib-tool.py-Emit-year-range-on-file-copyright-not.patch --]
[-- Type: text/x-patch, Size: 2166 bytes --]
From 67a69b85467f1641f5e8741a22c929cdf8268cd8 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.funk1@gmail.com>
Date: Wed, 28 Feb 2024 13:12:05 -0800
Subject: [PATCH] gnulib-tool.py: Emit year range on file copyright notices.
* pygnulib/GLInfo.py (GLInfo.copyright_range): New function. Return a
copyright string with a year range.
* pygnulib/GLEmiter.py (GLEmiter.copyright_notice): Use the new function
for file copyright headers.
---
ChangeLog | 8 ++++++++
pygnulib/GLEmiter.py | 2 +-
pygnulib/GLInfo.py | 4 ++++
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 8cfe498940..02d22de00f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-02-28 Collin Funk <collin.funk1@gmail.com>
+
+ gnulib-tool.py: Emit year range on file copyright notices.
+ * pygnulib/GLInfo.py (GLInfo.copyright_range): New function. Return a
+ copyright string with a year range.
+ * pygnulib/GLEmiter.py (GLEmiter.copyright_notice): Use the new function
+ for file copyright headers.
+
2024-02-28 Collin Funk <collin.funk1@gmail.com>
gnulib-tool.py: Make module sorting more similar to gnulib-tool.
diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py
index d8cc085f59..260478e5da 100644
--- a/pygnulib/GLEmiter.py
+++ b/pygnulib/GLEmiter.py
@@ -73,7 +73,7 @@ class GLEmiter(object):
'''GLEmiter.copyright_notice() -> str
Emit a header for a generated file.'''
- emit = "# %s" % self.info.copyright()
+ emit = '# %s' % self.info.copyright_range()
emit += """
#
# This file is free software; you can redistribute it and/or modify
diff --git a/pygnulib/GLInfo.py b/pygnulib/GLInfo.py
index a0a70270a9..1934fde103 100644
--- a/pygnulib/GLInfo.py
+++ b/pygnulib/GLInfo.py
@@ -125,6 +125,10 @@ class GLInfo(object):
result = re.compile(' .*').sub('', first_changelog_line)
return result
+ def copyright_range(self):
+ '''Returns a formated copyright string showing a year range.'''
+ return f'Copyright (C) {constants.__copyright__}'
+
def usage(self):
'''Show help message.'''
result = '''\
--
2.39.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: Can we have gnulib-tool.py emit the same copyright header?
2024-02-28 21:18 ` Collin Funk
@ 2024-02-28 21:30 ` Bruno Haible
2024-02-28 21:48 ` Collin Funk
0 siblings, 1 reply; 11+ messages in thread
From: Bruno Haible @ 2024-02-28 21:30 UTC (permalink / raw)
To: bug-gnulib, Collin Funk
Hi Collin,
> > I'm committing these three patches, that fix the version output also in the
> > presence of
> >
> > [log]
> > date = relative
>
> Nice. I wasn't aware of this option.
Neither was I. I searched through all possible git config variables whether any
could affect the "git log" output in a relevant way. Hope I didn't miss any.
> How does this patch look for fixing the copyright headers? I could
> have just used constants.__copyright__ in GLEmiter, but I thought it
> was best to put in GLInfo just in case it is needed elsewhere later.
Looks good, except for a typo or spelling mistake. [1]
Bruno
[1] https://en.wiktionary.org/wiki/formated
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Can we have gnulib-tool.py emit the same copyright header?
2024-02-28 21:30 ` Bruno Haible
@ 2024-02-28 21:48 ` Collin Funk
2024-02-28 23:34 ` Bruno Haible
0 siblings, 1 reply; 11+ messages in thread
From: Collin Funk @ 2024-02-28 21:48 UTC (permalink / raw)
To: Bruno Haible, bug-gnulib
[-- Attachment #1: Type: text/plain, Size: 183 bytes --]
On 2/28/24 1:30 PM, Bruno Haible wrote:
> Looks good, except for a typo or spelling mistake. [1]
I'm not the greatest at spelling apparently. Attached it with the typo fixed.
Collin
[-- Attachment #2: 0001-gnulib-tool.py-Emit-year-range-on-file-copyright-not.patch --]
[-- Type: text/x-patch, Size: 2167 bytes --]
From c21617ca4561f48225543378d0d4e24ac700877b Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.funk1@gmail.com>
Date: Wed, 28 Feb 2024 13:12:05 -0800
Subject: [PATCH] gnulib-tool.py: Emit year range on file copyright notices.
* pygnulib/GLInfo.py (GLInfo.copyright_range): New function. Return a
copyright string with a year range.
* pygnulib/GLEmiter.py (GLEmiter.copyright_notice): Use the new function
for file copyright headers.
---
ChangeLog | 8 ++++++++
pygnulib/GLEmiter.py | 2 +-
pygnulib/GLInfo.py | 4 ++++
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 8cfe498940..02d22de00f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-02-28 Collin Funk <collin.funk1@gmail.com>
+
+ gnulib-tool.py: Emit year range on file copyright notices.
+ * pygnulib/GLInfo.py (GLInfo.copyright_range): New function. Return a
+ copyright string with a year range.
+ * pygnulib/GLEmiter.py (GLEmiter.copyright_notice): Use the new function
+ for file copyright headers.
+
2024-02-28 Collin Funk <collin.funk1@gmail.com>
gnulib-tool.py: Make module sorting more similar to gnulib-tool.
diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py
index d8cc085f59..260478e5da 100644
--- a/pygnulib/GLEmiter.py
+++ b/pygnulib/GLEmiter.py
@@ -73,7 +73,7 @@ class GLEmiter(object):
'''GLEmiter.copyright_notice() -> str
Emit a header for a generated file.'''
- emit = "# %s" % self.info.copyright()
+ emit = '# %s' % self.info.copyright_range()
emit += """
#
# This file is free software; you can redistribute it and/or modify
diff --git a/pygnulib/GLInfo.py b/pygnulib/GLInfo.py
index a0a70270a9..08edb9b383 100644
--- a/pygnulib/GLInfo.py
+++ b/pygnulib/GLInfo.py
@@ -125,6 +125,10 @@ class GLInfo(object):
result = re.compile(' .*').sub('', first_changelog_line)
return result
+ def copyright_range(self):
+ '''Returns a formatted copyright string showing a year range.'''
+ return f'Copyright (C) {constants.__copyright__}'
+
def usage(self):
'''Show help message.'''
result = '''\
--
2.39.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: Can we have gnulib-tool.py emit the same copyright header?
2024-02-28 21:48 ` Collin Funk
@ 2024-02-28 23:34 ` Bruno Haible
0 siblings, 0 replies; 11+ messages in thread
From: Bruno Haible @ 2024-02-28 23:34 UTC (permalink / raw)
To: bug-gnulib, Collin Funk
Collin Funk wrote:
> Attached it with the typo fixed.
Thanks! Applied.
Bruno
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2024-02-28 23:35 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-28 1:41 Can we have gnulib-tool.py emit the same copyright header? Collin Funk
2024-02-28 2:07 ` Bruno Haible
2024-02-28 2:19 ` Collin Funk
2024-02-28 2:26 ` Bruno Haible
2024-02-28 2:51 ` Collin Funk
2024-02-28 7:53 ` Collin Funk
2024-02-28 11:00 ` Bruno Haible
2024-02-28 21:18 ` Collin Funk
2024-02-28 21:30 ` Bruno Haible
2024-02-28 21:48 ` Collin Funk
2024-02-28 23:34 ` Bruno Haible
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).