[latex3-commits] [git/LaTeX3-latex3-luaotfload] buildchange-dev: Accept `-dev` versions while tagging (28cd22b)

Marcel Fabian Krüger tex at 2krueger.de
Thu Sep 12 22:43:27 CEST 2019


Repository : https://github.com/latex3/luaotfload
On branch  : buildchange-dev
Link       : https://github.com/latex3/luaotfload/commit/28cd22b39dcbc25ecfd611cd6b93ae2a24d065df

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

commit 28cd22b39dcbc25ecfd611cd6b93ae2a24d065df
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Tue Aug 27 21:38:39 2019 +0200

    Accept `-dev` versions while tagging


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

28cd22b39dcbc25ecfd611cd6b93ae2a24d065df
 build.lua | 158 +++++++++++++++++++++++++++++---------------------------------
 1 file changed, 75 insertions(+), 83 deletions(-)

diff --git a/build.lua b/build.lua
index ee7e3a8..ac1b113 100644
--- a/build.lua
+++ b/build.lua
@@ -2,7 +2,7 @@
 packageversion= "3.002"
 packagedate   = "2019-08-11"
 packagedesc   = "ignorable"
-checkformat   = "latex-dev" -- for travis until something better comes up
+checkformat   = "latex" -- for travis until something better comes up
 
 module   = "luaotfload"
 ctanpkg  = "luaotfload"
@@ -19,16 +19,15 @@ print(mydata.email)
 
 --------- setup things for a dev-version
 -- See stackoverflow.com/a/12142066/212001 / build-config from latex2e
-local master_branch = true
-do
+local master_branch do
   local branch = os.getenv'TRAVIS_BRANCH'
   if not branch then
     local f = io.popen'git rev-parse --abbrev-ref HEAD'
     branch = f:read'*a':sub(1,-2)
     assert(f:close())
   end
-  if string.match(branch, "dev") then
-    master_branch = false
+  master_branch = string.match(branch, '^master')
+  if not master_branch then
     tdsroot = "latex-dev"
     print("creating/installing dev-version in " .. tdsroot)
     ctanpkg = ctanpkg .. "-dev"
@@ -227,86 +226,79 @@ function typeset_demo_tasks()
  return 0
 end
 
-function update_tag (file,content,tagname,tagdate)
- tagdate = string.gsub (packagedate,"-", "/")
- if string.match (file, "%.sty$" ) then
-  content = string.gsub (content,  
-                         "%d%d%d%d/%d%d/%d%d [a-z]+%d%.%d+",
-                         tagdate.." v"..packageversion)
-  return content  
- elseif string.match (file,"fontloader%-basic") then
-  if master_branch then
-    content = string.gsub (content,
-                           "caches.namespace = 'generic%-dev'",
-                           "caches.namespace = 'generic'")
-  else 
-   content = string.gsub (content,
-                           "caches.namespace = 'generic'",
-                           "caches.namespace = 'generic-dev'")
+local function lpeggsub(pattern)
+  return lpeg.Cs(lpeg.P{pattern + (1 * (lpeg.V(1) + -1))}^0)
+end
+local digit = lpeg.R'09'
+local spaces = lpeg.P' '^1
+local function lpegrep(pattern,times)
+  if times == 0 then return true end
+  return pattern * lpegrep(pattern, times - 1)
+end
+local tagdatepat = lpeg.Cg( -- Date: YYYY/MM/DD
+  lpegrep(digit, 4) * lpegrep('/' * digit * digit, 2)
+  * lpeg.Cc(string.gsub(packagedate, '-', '/')))
+local packagedatepat = lpeg.Cg( -- Date: YYYY-MM-DD
+  lpegrep(digit, 4) * lpegrep('-' * digit * digit, 2)
+  * lpeg.Cc(packagedate))
+local imgpackagedatepat = lpeg.Cg( -- Date: YYYY--MM--DD
+  lpegrep(digit, 4) * lpegrep('--' * digit * digit, 2)
+  * lpeg.Cc(string.gsub(packagedate, '-', '--')))
+local xxxpackagedatepat = lpeg.Cg( -- Date: YYYYxxxMMxxxDD
+  lpegrep(digit, 4) * lpegrep('xxx' * digit * digit, 2)
+  * lpeg.Cc(string.gsub(packagedate, '-', 'xxx')))
+local packageversionpat = lpeg.Cg( -- Version: M.mmmm-dev
+  digit * '.' * digit^1 * lpeg.P'-dev'^-1
+  * lpeg.Cc(packageversion))
+local sty_pattern = lpeggsub(tagdatepat * ' v' * packageversionpat)
+local tex_pattern = lpeggsub(packagedatepat * ' v' * packageversionpat)
+local lua_pattern = lpeggsub(
+      'version' * spaces * '=' * spaces
+           * '"' * packageversionpat * '",' * spaces * '--TAGVERSION'
+    + 'date' * spaces * '=' * spaces
+           * '"' * packagedatepat * '",' * spaces * '--TAGDATE')
+local readme_pattern = lpeggsub(
+      (lpeg.P'Version: ' + 'version-' + 'for ') * packageversionpat
+    + packagedatepat + imgpackagedatepat)
+local ctanreadme_pattern = lpeggsub(
+      'VERSION: ' * packageversionpat
+    + 'DATE: ' * packagedatepat)
+local rst_pattern = lpeggsub(
+      ':Date:' * spaces * packagedatepat
+    + ':Version:' * spaces * packageversionpat)
+local status_pattern = lpeggsub('v' * packageversionpat * '/' * packagedatepat)
+local fontloader_pattern = lpeggsub(
+      packageversionpat * ' with fontloaderxxx' * xxxpackagedatepat)
+function update_tag (file,content,_tagname,_tagdate)
+  if string.match (file, "%.sty$" ) then
+    return sty_pattern:match(content)
+  elseif string.match (file,"fontloader%-basic") then
+   if master_branch then
+     return string.gsub (content,
+                          "caches.namespace = 'generic%-dev'",
+                          "caches.namespace = 'generic'")
+   else
+     return string.gsub (content,
+                          "caches.namespace = 'generic'",
+                          "caches.namespace = 'generic-dev'")
+   end
+  elseif string.match (file, "%.lua$") then
+    return lua_pattern:match(content)
+  elseif file == 'README.md$' then
+    return readme_pattern:match(content)
+  elseif string.match (file, "CTANREADME.md$") then
+    return ctanreadme_pattern:match(content)
+  elseif string.match (file, "%.tex$" ) then
+    return tex_pattern:match(content)
+  elseif string.match (file, "%.rst$" ) then
+    return rst_pattern:match(content)
+  elseif string.match (file,"mkstatus$") then
+    return status_pattern:match(content)
+  elseif string.match (file,"aaaaa%-luakern") then
+    return fontloader_pattern:match(content)
   end
   return content
- elseif string.match (file, "%.lua$") then
-  content = string.gsub (content,  
-                         '(version%s*=%s*")%d%.%d+(",%s*--TAGVERSION)',
-                         "%1"..packageversion.."%2")
-  content = string.gsub (content,  
-                         '(date%s*=%s*")%d%d%d%d%-%d%d%-%d%d(",%s*--TAGDATE)',
-                         "%1"..packagedate.."%2")                                                                                           
-  return content                         
- elseif string.match (file, "^README.md$") then
-   content = string.gsub (content,  
-                         "Version: %d%.%d+",
-                         "Version: " .. packageversion )
-   content = string.gsub (content,  
-                         "version%-%d%.%d+",
-                         "version-" .. packageversion ) 
-   content = string.gsub (content,  
-                         "for %d%.%d+",
-                         "for " .. packageversion ) 
-   content = string.gsub (content,  
-                         "%d%d%d%d%-%d%d%-%d%d",
-                         packagedate )
-   local imgpackagedate = string.gsub (packagedate,"%-","--")                          
-   content = string.gsub (content,  
-                         "%d%d%d%d%-%-%d%d%-%-%d%d",
-                         imgpackagedate)                                                                                                     
-   return content
- elseif string.match (file, "CTANREADME.md$") then
-   content = string.gsub (content,  
-                         "VERSION: %d%.%d+",
-                         "VERSION: " .. packageversion )
-   content = string.gsub (content,  
-                         "DATE: %d%d%d%d%-%d%d%-%d%d",
-                         "DATE: " .. packagedate )                                                                          
-   return content   
- elseif string.match (file, "%.tex$" ) then
-   content = string.gsub (content,  
-                         "%d%d%d%d%-%d%d%-%d%d v%d%.%d+",
-                         packagedate.." v"..packageversion)
-  return content    
- elseif string.match (file, "%.rst$" ) then
-   content = string.gsub (content,  
-                         "(:Date:%s+)%d%d%d%d%-%d%d%-%d%d",
-                         "%1"..packagedate)
-  content = string.gsub (content,  
-                         "(:Version:%s+)%d%.%d+",
-                         "%1"..packageversion)                       
-  return content 
- elseif string.match (file,"mkstatus") then
-  content= string.gsub (content,  
-                         "v%d%.%d+/%d%d%d%d%-%d%d%-%d%d",
-                         "v"..packageversion.."/"..packagedate)
- 
-  return content
- elseif string.match (file,"aaaaa%-luakern") then   
-    content= string.gsub (content,  
-                         "%d%.%d+%swith%sfontloaderxxx%d%d%d%dxxx%d%dxxx%d%d",
-                         packageversion.." with fontloaderxxx"..string.gsub(packagedate,"[%-]","xxx"))
-
-   return content                           
- end
- return content
- end
+end
 
 
 kpse.set_program_name ("kpsewhich")





More information about the latex3-commits mailing list