Skip to content

Commit

Permalink
Update copyright.js tool
Browse files Browse the repository at this point in the history
It will now properly sort authors by date, and follow renames, which should give a much better coverage of copyright information.
  • Loading branch information
Xaymar committed Sep 30, 2023
1 parent 0e913ed commit 4339a5f
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions tools/copyright.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ async function git_retrieveAuthors(file) {
let proc = CHILD_PROCESS.spawn("git", [
"--no-pager",
"log",
"--date-order",
"--reverse",
"--follow",
"--format=format:%aI|%aN <%aE>",
"--",
file
Expand Down Expand Up @@ -190,7 +189,11 @@ async function git_retrieveAuthors(file) {

let author = authors.get(name);
if (author) {
author.to = new Date(date)
let dt = new Date(date)
if (author.from > dt)
author.from = dt;
if (author.to < dt)
author.to = dt;
} else {
authors.set(name, {
from: new Date(date),
Expand All @@ -203,6 +206,14 @@ async function git_retrieveAuthors(file) {

async function generateCopyright(file) {
let authors = await git_retrieveAuthors(file)
authors = new Map([...authors].sort((a, b) => {
if (a[1].from < b[1].from) {
return -1;
} else if (a[1].from > b[1].from) {
return 1;
}
return 0;
}));
let lines = [];
for (let entry of authors) {
let from = entry[1].from.getUTCFullYear();
Expand Down

0 comments on commit 4339a5f

Please sign in to comment.