module (..., package.seeall) -- Load libraries require("fs") require("format") -- ################################################################################ -- LOCAL FUNCTIONS local function querycmd ( cmdline ) local cmd = io.popen( cmdline ) local cmd_result = cmd:read("*a") or "unknown" cmd:close() return cmd_result end -- ################################################################################ -- PUBLIC FUNCTIONS function get (self) local svnurl = "svn://svn.alpinelinux.org/acf/" return querycmd("/usr/bin/svn list -v " .. svnurl ) end function update (self) local svnurl = "svn://svn.alpinelinux.org/acf/" local updates = {} local cmdresult = {} updates.svnurl = svnurl for list in string.gmatch((querycmd("/usr/bin/svn list " .. svnurl )), "%S+") do local updateresult = "" if (list == "core/") then updateresult = querycmd("/usr/bin/svn up /usr/share/acf/ 2>&1") elseif (list == "skins/") and ( fs.is_dir("/usr/share/acf/www/" .. list)) then updateresult = querycmd("/usr/bin/svn up /usr/share/acf/www/skins 2>&1") elseif (list == "skins/") and not ( fs.is_dir("/usr/share/acf/www/" .. list)) then updateresult = querycmd("/usr/bin/svn co " .. svnurl .. list .."trunk/ /usr/share/acf/www/" .. list .. " 2>&1") elseif (list == "skins/") then updateresult = querycmd("/usr/bin/svn up /usr/share/acf/www/skins 2>&1") elseif ( fs.is_dir("/usr/share/acf/app/" .. list)) then updateresult = querycmd("/usr/bin/svn up /usr/share/acf/app/" .. list .. " 2>&1") elseif (list ~= "sandbox/") then updateresult = querycmd("/usr/bin/svn co " .. svnurl .. list .."trunk/ /usr/share/acf/app/" .. list .. " 2>&1") end -- Hide projects without updates if (string.match(updateresult, "^At revision.*")) then updateresult = "" end table.insert(cmdresult, {name=list, updates=updateresult}) end updates.cmdresult = cmdresult return updates end function diffs (self) local svnurl = "svn://svn.alpinelinux.org/acf/" local updates = {} local cmdresult = {} updates.svnurl = svnurl table.insert(cmdresult, {name="INFORMATION", updates="

Important information.

In the following output all html-brackets < and > are replaced to [ and ].
This is to be able to display the diffs in text (perhibit the browser to display the diff as graphics).

"}) for list in string.gmatch((querycmd("/usr/bin/svn list " .. svnurl )), "%S+") do local updateresult = "" if (list == "core/") then updateresult = querycmd("/usr/bin/svn -rHEAD diff /usr/share/acf/ 2>&1") elseif ( fs.is_dir("/usr/share/acf/app/" .. list)) then updateresult = querycmd("/usr/bin/svn -rHEAD diff /usr/share/acf/app/" .. list .. " 2>&1") end updateresult = format.search_replace({updateresult},"<","[") updateresult = format.search_replace(updateresult,">","]") updateresult = table.concat(updateresult, "\n") table.insert(cmdresult, {name=list, updates=updateresult}) end updates.cmdresult = cmdresult return updates end function status (self) local svnurl = "svn://svn.alpinelinux.org/acf/" local updates = {} local cmdresult = {} updates.svnurl = svnurl for list in string.gmatch((querycmd("/usr/bin/svn list " .. svnurl )), "%S+") do local updateresult = "" if (list == "core/") then updateresult = querycmd("/usr/bin/svn st -u /usr/share/acf/ 2>&1") elseif ( fs.is_dir("/usr/share/acf/app/" .. list)) then updateresult = querycmd("/usr/bin/svn st -u /usr/share/acf/app/" .. list .. " 2>&1") end -- Hide projects without diffs if (string.match(updateresult, "^Status against revision.*")) then updateresult = "" end table.insert(cmdresult, {name=list, updates=updateresult}) end updates.cmdresult = cmdresult return updates end function log (self) local svnurl = "svn://svn.alpinelinux.org/acf/" local updates = {} local cmdresult = {} local enddate = tostring(os.date("%Y-%m-%d", (os.time() - (3600 * 24) * 7))) local svnresult = querycmd("/usr/bin/svn log -v -rHEAD:{".. enddate .. "} " .. svnurl ) local svnheader = os.date("%Y-%m-%d") local svnupdates = "" table.insert(cmdresult, {name="INFORMATION", updates="

This is the result of svn log 1 week back in time.

svn log -v -rHEAD:{".. enddate .. "} " .. svnurl .. "

"}) for v in string.gmatch(svnresult,"(.-\n)") do local svnheader_tmp = string.match(v, "r%d+%s+.-(%d+%-%d+%-%d+)") if (svnheader_tmp) and (svnheader_tmp ~= svnheader) then table.insert(cmdresult,{ ["updates"] = svnupdates, ["name"] = svnheader, }) svnheader = svnheader_tmp svnupdates = "" end svnupdates = svnupdates .. v end updates.cmdresult = cmdresult return updates end