[latex3-commits] [git/LaTeX3-latex3-latex2e] develop: First step in auto-editing copyright (4010f117)

Joseph Wright joseph.wright at morningstar2.co.uk
Tue Jul 30 14:33:30 CEST 2019


Repository : https://github.com/latex3/latex2e
On branch  : develop
Link       : https://github.com/latex3/latex2e/commit/4010f117b844207df1b60f22163e87640207a417

>---------------------------------------------------------------

commit 4010f117b844207df1b60f22163e87640207a417
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Tue Jul 30 13:33:30 2019 +0100

    First step in auto-editing copyright
    
    Does base, will do some others ...


>---------------------------------------------------------------

4010f117b844207df1b60f22163e87640207a417
 base/build.lua   | 18 +++++++++++++++++-
 build-config.lua | 21 +++++++++++++++++++--
 2 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/base/build.lua b/base/build.lua
index d9edf0b9..2eaeb5ce 100644
--- a/base/build.lua
+++ b/base/build.lua
@@ -142,8 +142,24 @@ indexstyle = "source2e.ist"
 checkconfigs = {"build","config-TU"}
 
 -- Detail how to set the version automatically
-tagfiles = {"README.md", "ltvers.dtx"}
 function update_tag(file,content,tagname,tagdate)
+  local year = os.date("%Y")
+  if string.match(content,"%% Copyright %d%d%d%d%-%d%d%d%d") then
+    content = string.gsub(content,
+      "Copyright (%d%d%d%d)%-%d%d%d%d",
+      "Copyright %1-" .. year)
+  elseif string.match(content,"%% Copyright %d%d%d%d\n") then
+    local oldyear = string.match(content,"%% Copyright (%d%d%d%d)\n")
+    if not year == oldyear then
+      content = string.gsub(content,
+        "Copyright %d%d%d%d",
+        "Copyright " .. oldyear .. "-" .. year)
+    end
+  end
+  if not string.match(file,"%.md$") or not string.match(file,"ltvers.dtx") then
+    -- Stop here for files other than .md
+    return content
+  end
   local iso = "%d%d%d%d%-%d%d%-%d%d"
   local tag, rev = string.match(tagname,"^(.*):([^:]*)$")
   local patch_level = ""
diff --git a/build-config.lua b/build-config.lua
index 164277f2..d4528288 100644
--- a/build-config.lua
+++ b/build-config.lua
@@ -15,7 +15,7 @@ checkruns      = checkruns          or  2
 checksuppfiles = checksuppfiles     or
   {"color.cfg", "graphics.cfg", "test209.tex", "test2e.tex", "xetex.def", "dvips.def", "lipsum.sty"}
 stdengine      = stdengine          or "etex"
-tagfiles       = tagfiles or {"README.md"}
+tagfiles       = tagfiles or {"*.dtx","*.ins","*.tex","README.md"}
 typesetsuppfiles = typesetsuppfiles or {"ltxdoc.cfg", "ltxguide.cfg"}
 
 -- Ensure the local format file is used
@@ -63,8 +63,25 @@ end
 
 -- Detail how to set the version automatically
 update_tag = update_tag or function (file,content,tagname,tagdate)
+  local year = os.date("%Y")
+  if string.match(content,"%% Copyright %d%d%d%d%-%d%d%d%d") then
+    content = string.gsub(content,
+      "Copyright (%d%d%d%d)%-%d%d%d%d",
+      "Copyright %1-" .. year)
+  elseif string.match(content,"%% Copyright %d%d%d%d\n") then
+    local oldyear = string.match(content,"%% Copyright (%d%d%d%d)\n")
+    if not year == oldyear then
+      content = string.gsub(content,
+        "Copyright %d%d%d%d",
+        "Copyright " .. oldyear .. "-" .. year)
+    end
+  end
+  if not string.match(file,"%.md$") then
+    -- Stop here for files other than .md
+    return content
+  end
   local iso = "%d%d%d%d%-%d%d%-%d%d"
-  local tag, rev = string.match(tagname,"^(.*):([^:]*)$")
+  local tag, rev = string.match(tagname,"^(.*):?([^:]*)$")
   if master_branch then
     if rev then
       tag = tag .. " patch level " .. rev





More information about the latex3-commits mailing list