Update copyright notices in libraries with the help of an auto-generator

This commit is contained in:
Nguyễn Gia Phong 2019-09-01 17:58:13 +07:00
parent d533a1d190
commit 08170d67ff
5 changed files with 169 additions and 19 deletions

View File

@ -16,6 +16,7 @@ Added:
- `helpers.setasyncall` to avoid writing redundant workers for asynchronous - `helpers.setasyncall` to avoid writing redundant workers for asynchronous
widget types. Note that these workers are only needed in case Vicious is used widget types. Note that these workers are only needed in case Vicious is used
as a stand-alone library. as a stand-alone library.
- `headergen` script for automatic generation of copyright notices.
Fixed: Fixed:
@ -30,6 +31,7 @@ Fixed:
- [pkg] Use more updated front-ends for Debian/Ubuntu (apt) and Fedora (dnf) - [pkg] Use more updated front-ends for Debian/Ubuntu (apt) and Fedora (dnf)
- [os] Splitted os_all into os_linux and os_bsd (and refactored to async) - [os] Splitted os_all into os_linux and os_bsd (and refactored to async)
- Tweak `.luacheckrc` to suit functional style and soft-limit text width to 80 - Tweak `.luacheckrc` to suit functional style and soft-limit text width to 80
- Update copyright headers for libraries
Removed: Removed:

100
headergen Executable file
View File

@ -0,0 +1,100 @@
#!/usr/bin/env lua
-- copyright header generator
-- Copyright (C) 2019 Nguyễn Gia Phong
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
local ipairs = ipairs
local pairs = pairs
local tonumber = tonumber
local io = { open = io.open, popen = io.popen }
local os = { exit = os.exit }
local table = {
concat = table.concat,
insert = table.insert,
sort = table.sort
}
local HEADER = [[-- %s
%s
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
%s]]
local COMMAND = "git log --date=format:%Y --format='%ad %an <%ae>' "
if #arg == 0 then
print'usage: headergen lua-source-files'
os.exit(1)
end
for _, filename in ipairs(arg) do
local fi = io.open(filename)
local content = fi:read'*a'
fi:close()
local holders = {}
local output = io.popen(COMMAND .. filename)
for line in output:lines() do
local year, author = line:match'(%d+)%s+(.+)'
if holders[author] == nil then holders[author] = {} end
holders[author][year] = true
end
output:close()
local copyrights = {}
for author, years in pairs(holders) do
local time = {}
for year, _ in pairs(years) do table.insert(time, tonumber(year)) end
table.sort(time)
local copyright = { 'Copyright (C) ' }
for _, current in ipairs(time) do
local prev = tonumber(copyright[#copyright])
if prev == nil then
table.insert(copyright, current)
elseif current - 1 ~= prev then
table.insert(copyright, ',')
table.insert(copyright, current)
elseif copyright[#copyright - 1] == '-' then
copyright[#copyright] = current
else
table.insert(copyright, '-')
table.insert(copyright, current)
end
end
table.insert(copyrights,
('-- %s %s'):format(table.concat(copyright), author))
end
local fo = io.open(filename, 'w')
table.sort(copyrights)
fo:write(HEADER:format(filename, table.concat(copyrights, '\n'), content))
fo:close()
end

View File

@ -1,11 +1,34 @@
--------------------------------------------------- -- helper functions
-- Licensed under the GNU General Public License v2 -- Copyright (C) 2009 Benedikt Sauer <filmor@gmail.com>
-- * (c) 2010, Adrian C. <anrxc@sysphere.org> -- Copyright (C) 2009 Henning Glawe <glaweh@debian.org>
-- * (c) 2009, Rémy C. <shikamaru@mandriva.org> -- Copyright (C) 2009 Lucas de Vries <lucas@glacicle.com>
-- * (c) 2009, Benedikt Sauer <filmor@gmail.com> -- Copyright (C) 2009 Rémy C. <shikamaru@mandriva.org>
-- * (c) 2009, Henning Glawe <glaweh@debian.org> -- Copyright (C) 2009-2012 Adrian C. (anrxc) <anrxc@sysphere.org>
-- * (c) 2009, Lucas de Vries <lucas@glacicle.com> -- Copyright (C) 2011 Joerg T. (Mic92) <jthalheim@gmail.com>
--------------------------------------------------- -- Copyright (C) 2012 Arvydas Sidorenko <asido4@gmail.com>
-- Copyright (C) 2012 Jörg Thalheim <jthalheim@gmail.com>
-- Copyright (C) 2014-2015 Jörg Thalheim <joerg@higgsboson.tk>
-- Copyright (C) 2017 Joerg Thalheim <joerg@thalheim.io>
-- Copyright (C) 2017,2019 mutlusun <mutlusun@github.com>
-- Copyright (C) 2017-2018 Jörg Thalheim <joerg@thalheim.io>
-- Copyright (C) 2018-2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
-- Copyright (C) 2019 Alexander Koch <lynix47@gmail.com>
-- Copyright (C) 2019 Enric Morales <me@enric.me>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment -- {{{ Grab environment
local pairs = pairs local pairs = pairs

View File

@ -1,10 +1,35 @@
--------------------------------------------------- -- Vicious module initialization
-- Vicious widgets for the awesome window manager -- Copyright (C) 2009 Lucas de Vries <lucas@glacicle.com>
--------------------------------------------------- -- Copyright (C) 2009-2013 Adrian C. (anrxc) <anrxc@sysphere.org>
-- Licensed under the GNU General Public License v2 -- Copyright (C) 2011 Joerg T. (Mic92) <jthalheim@gmail.com>
-- * (c) 2010, Adrian C. <anrxc@sysphere.org> -- Copyright (C) 2012 Arvydas Sidorenko <asido4@gmail.com>
-- * (c) 2009, Lucas de Vries <lucas@glacicle.com> -- Copyright (C) 2012 Jörg Thalheim <jthalheim@gmail.com>
--------------------------------------------------- -- Copyright (C) 2013 Dodo <dodo.the.last@gmail.com>
-- Copyright (C) 2013-2014,2017 Jörg Thalheim <joerg@higgsboson.tk>
-- Copyright (C) 2014 blastmaster <blastmaster@tuxcode.org>
-- Copyright (C) 2015 Daniel Hahler <git@thequod.de>
-- Copyright (C) 2017 James Reed <supplantr@users.noreply.github.com>
-- Copyright (C) 2017 Joerg Thalheim <joerg@thalheim.io>
-- Copyright (C) 2017 getzze <getzze@gmail.com>
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
-- Copyright (C) 2018 Beniamin Kalinowski <beniamin.kalinowski@gmail.com>
-- Copyright (C) 2018 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
-- Copyright (C) 2019 Daniel Hahler <github@thequod.de>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Setup environment -- {{{ Setup environment
local type = type local type = type

View File

@ -1,5 +1,5 @@
-- spawn.lua - wrapper around Awesome awful.spawn with fallback -- wrapper around Awesome awful.spawn with fallback
-- Copyright (C) 2019 Nguyễn Gia Phong -- Copyright (C) 2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
-- --
-- This file is part of Vicious. -- This file is part of Vicious.
-- --
@ -11,9 +11,9 @@
-- Vicious is distributed in the hope that it will be useful, -- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of -- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU Affero General Public License for more details. -- GNU General Public License for more details.
-- --
-- You should have received a copy of the GNU Affero General Public License -- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>. -- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
local status, awful = pcall(require, "awful") local status, awful = pcall(require, "awful")