diff --git a/Changes.md b/Changes.md index bc453fa..ee03d38 100644 --- a/Changes.md +++ b/Changes.md @@ -16,6 +16,7 @@ Added: - `helpers.setasyncall` to avoid writing redundant workers for asynchronous widget types. Note that these workers are only needed in case Vicious is used as a stand-alone library. +- `headergen` script for automatic generation of copyright notices. Fixed: @@ -30,6 +31,7 @@ Fixed: - [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) - Tweak `.luacheckrc` to suit functional style and soft-limit text width to 80 +- Update copyright headers for libraries Removed: diff --git a/headergen b/headergen new file mode 100755 index 0000000..8170cf5 --- /dev/null +++ b/headergen @@ -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 . + +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 . + +%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 diff --git a/helpers.lua b/helpers.lua index c3d4a22..523e73a 100644 --- a/helpers.lua +++ b/helpers.lua @@ -1,11 +1,34 @@ ---------------------------------------------------- --- Licensed under the GNU General Public License v2 --- * (c) 2010, Adrian C. --- * (c) 2009, Rémy C. --- * (c) 2009, Benedikt Sauer --- * (c) 2009, Henning Glawe --- * (c) 2009, Lucas de Vries ---------------------------------------------------- +-- helper functions +-- Copyright (C) 2009 Benedikt Sauer +-- Copyright (C) 2009 Henning Glawe +-- Copyright (C) 2009 Lucas de Vries +-- Copyright (C) 2009 Rémy C. +-- Copyright (C) 2009-2012 Adrian C. (anrxc) +-- Copyright (C) 2011 Joerg T. (Mic92) +-- Copyright (C) 2012 Arvydas Sidorenko +-- Copyright (C) 2012 Jörg Thalheim +-- Copyright (C) 2014-2015 Jörg Thalheim +-- Copyright (C) 2017 Joerg Thalheim +-- Copyright (C) 2017,2019 mutlusun +-- Copyright (C) 2017-2018 Jörg Thalheim +-- Copyright (C) 2018-2019 Nguyễn Gia Phong +-- Copyright (C) 2019 Alexander Koch +-- Copyright (C) 2019 Enric Morales +-- +-- 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 . -- {{{ Grab environment local pairs = pairs diff --git a/init.lua b/init.lua index e10d4d6..10a5865 100644 --- a/init.lua +++ b/init.lua @@ -1,10 +1,35 @@ ---------------------------------------------------- --- Vicious widgets for the awesome window manager ---------------------------------------------------- --- Licensed under the GNU General Public License v2 --- * (c) 2010, Adrian C. --- * (c) 2009, Lucas de Vries ---------------------------------------------------- +-- Vicious module initialization +-- Copyright (C) 2009 Lucas de Vries +-- Copyright (C) 2009-2013 Adrian C. (anrxc) +-- Copyright (C) 2011 Joerg T. (Mic92) +-- Copyright (C) 2012 Arvydas Sidorenko +-- Copyright (C) 2012 Jörg Thalheim +-- Copyright (C) 2013 Dodo +-- Copyright (C) 2013-2014,2017 Jörg Thalheim +-- Copyright (C) 2014 blastmaster +-- Copyright (C) 2015 Daniel Hahler +-- Copyright (C) 2017 James Reed +-- Copyright (C) 2017 Joerg Thalheim +-- Copyright (C) 2017 getzze +-- Copyright (C) 2017 mutlusun +-- Copyright (C) 2018 Beniamin Kalinowski +-- Copyright (C) 2018 Nguyễn Gia Phong +-- Copyright (C) 2019 Daniel Hahler +-- +-- 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 . -- {{{ Setup environment local type = type diff --git a/spawn.lua b/spawn.lua index 620d563..afe7802 100644 --- a/spawn.lua +++ b/spawn.lua @@ -1,5 +1,5 @@ --- spawn.lua - wrapper around Awesome awful.spawn with fallback --- Copyright (C) 2019 Nguyễn Gia Phong +-- wrapper around Awesome awful.spawn with fallback +-- Copyright (C) 2019 Nguyễn Gia Phong -- -- This file is part of Vicious. -- @@ -11,9 +11,9 @@ -- 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 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 . local status, awful = pcall(require, "awful")