[m-rev.] for review: Add a tool to help maintain Copyright lines.

Zoltan Somogyi zoltan.somogyi at runbox.com
Fri Feb 9 18:28:31 AEDT 2024


On 2024-02-09 18:17 +11:00 AEDT, "Peter Wang" <novalazy at gmail.com> wrote:
> On Fri, 09 Feb 2024 15:55:00 +1100 "Zoltan Somogyi" <zoltan.somogyi at runbox.com> wrote:
>> 
>> On 2024-02-09 15:16 +11:00 AEDT, "Peter Wang" <novalazy at gmail.com> wrote:
>> > tools/update_copyright.m:
>> > tools/.gitignore:
>> >     Add the update_copyright program. It is deliberately not integrated
>> >     into the build system as it should be compiled once, manually, then
>> >     left in the workspace across checkouts, mmake clean, etc.
>> 
>> The update_copyright program should go into its own directory.
>> I wouldn't want to start mixing Mercury code with sh code.
>> 
> 
> What should I name the directory, update_copyright? Or maybe git_hooks?

Probably the latter, since it is more future-proof.

>> I would add a comment about dummy being there to make the pred multi,
>> or, even better I would replace that "option" with another, -q for quiet
>> (since -s for silent would clash with suffix) which shuts up any non-error output.
>> 
> 
> You can add it if you like.

Will do.

> I tried it, but I don't find it better for two reasons:
> 
> There is no read_input_stream_as_lines so the stdin case ends up
> having to call read_file_as_string and split_into_lines.
> (We could delete the code for stdin as well; /dev/stdin can be passed on
> the command line if it's useful.)

The NonOptionArgs = [] case can just invoke process_file on /dev/stdin.

> read_named_file_as_lines loses the newlines at the end of each line,
> which will need to be added to the output. Files SHOULD have a final
> newline, but I'd rather preserve the input as much as possible.

It is trivial to add them back in. I set up read_named_files_as_lines
to delete the final \n on each line because that is what the use cases
I wrote it for wanted, but it would be easy to add a sister predicate
that keeps the \ns. They could keep a common implementation,
they could just pass different values of the KeepNewlines flag.

>> If you want, you can commit the code as is, and I would rewrite it along
>> the above lines.
>> 
> 
> You can do it if you want.

Will do.

The interdiff is fine.

Zoltan.


More information about the reviews mailing list