0

A git repository has many files and each file should get a SPDX license header. The license header should be created by reuse and use the year of creation as year in the copyright.

example of what I want to get:  

$> head -v -n1 *.py       # Prints first line of each file

==> made_on_2006-01-01.py  <==
# SPDX-FileCopyrightText: 2006 Bob Doe <bob@example.com>

==> made_on_2012-02-02.py  <==
# SPDX-FileCopyrightText: 2012 Alice Doe <alice@example.com>

==> made_on_2020-03-03.py  <==
# SPDX-FileCopyrightText: 2020 Bob Doe <bob@example.com>

How can I create these headers with reuse, git and standard command line tools on Linux?

I think this is useful for projects with a single coder where you want to note the copyright with the first day of file creation.

Jonas Stein
  • 6,826
  • 7
  • 40
  • 72
  • 1
    So the real question seems to be: how to extract creation date and author's name using git and run [`reuse addheader --copyright="John Doe" --license GPL-2.0 --year 2022`](https://reuse.readthedocs.io/en/stable/usage.html#addheader); repeat for every file. – phd Oct 06 '22 at 22:02
  • So my advice is to split the task into small steps and then combine solutions. Task number 1: list all files in the repository (in the HEAD commit, actually). https://stackoverflow.com/a/444317/7976758 Found in https://stackoverflow.com/search?q=%5Bgit%5D+list+files – phd Oct 06 '22 at 22:10
  • Task №2: for every file find its creation date: https://stackoverflow.com/a/72614438/7976758 Found in https://stackoverflow.com/search?q=%5Bgit%5D+creation+date The command can be extended to provide author name: `--format=%aN` – phd Oct 06 '22 at 22:12

0 Answers0