summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2012-11-10 14:28:07 +0000
committerDaniel Silverstone <dsilvers@digital-scurf.org>2012-11-10 14:28:07 +0000
commit23bc9af7ecfab299a962cc1a356cf072531ba54e (patch)
tree1ef3d108bcdd26126b1eb195ea0297bd684d9c11
parenta9d1bbbbd1a91981a40efc606286c640cb997a5b (diff)
downloadgitano-23bc9af7ecfab299a962cc1a356cf072531ba54e.tar.gz
Remove dead code
-rw-r--r--lib/gitano/actions.lua173
1 files changed, 0 insertions, 173 deletions
diff --git a/lib/gitano/actions.lua b/lib/gitano/actions.lua
index b0aec5c..d6f70f7 100644
--- a/lib/gitano/actions.lua
+++ b/lib/gitano/actions.lua
@@ -99,177 +99,6 @@ local function http_post(host, path, content_type, body)
}, body)
end
-local cia_pattern = [[
-<message>
- <generator>
- <name>gitano</name>
- <version>1</version>
- <url>http://www.gitano.org.uk/</url>
- </generator>
- <source>
- <project>%s</project>
- <branch>%s</branch>
- </source>
- <body>
-%s
- </body>
-</message>
-]]
-
-local cia_commit_pattern = [[
- <commit>
- <version>%s</version>
- <files>
- %s
- </files>
- <author>%s</author>
- <log>%s</log>
- </commit>]]
-
-local function cia_branch_update_gen(project, branch, repo,
- previoustip, newtip)
- previoustip = previoustip:gsub("[^0-9a-fA-F]", "")
- newtip = newtip:gsub("[^0-9a-fA-F]", "")
-
- local revs = repo.git:rev_list(previoustip, newtip, true)
- if type(revs) ~= "table" then
- revs = { newtip }
- end
- local commits = {}
-
- local base, msg = repo.git:merge_base(previoustip, newtip)
- local is_rebase = false
- if not base then
- gitano.log.fatal(msg)
- elseif (base == true) or ((base) and (base == newtip)) then
- is_rebase = true
- else
- is_rebase = false
- end
-
- local suffix = ""
- local nrevs = #revs
- if is_rebase then
- nrevs = 1
- suffix = "+rebase"
- else
- if nrevs > 4 then
- nrevs = 3
- suffix = "+more"
- end
- end
-
- for i = nrevs, 1, -1 do
- local commit = repo.git:get(revs[i])
- local author = commit.content.author
- author = ("%s <%s>"):format(author.realname, author.email)
- author = util.html_escape(author)
- local logline = commit.content.message:match("^([^\r\n]+)")
- logline = util.html_escape(logline)
- local mytree = commit.content.tree.content
- local parent = commit.content.parents[1]
- if parent then
- parent = parent.content.tree.content
- else
- parent = repo.git:get(gall.tree.empty_sha).content
- end
- local treedelta = parent:diff_to(mytree)
- local filelist = {}
- for i, v in ipairs(treedelta) do
- local fmts = { "UNKNOWN_ACTION", "", util.html_escape(v.filename) }
- if v.action == "A" then
- fmts[1] = "add"
- elseif v.action == "D" then
- fmts[1] = "remove"
- elseif v.action == "R" then
- fmts[1] = "rename"
- fmts[2] = ([[ to=%q]]):format(fmts[3])
- fmts[3] = util.html_escape(v.src_name)
- elseif v.action == "C" then
- -- for copy we treat the new file as an add
- fmts[1] = "add"
- elseif v.action == "M" then
- fmts[1] = "modify"
- else
- log.ddebug("Unknown action", v.action,
- "in CIA commit formatter, assuming modify")
- fmts[1] = "modify"
- end
- filelist[#filelist+1] =
- ([[<file action="%s"%s>%s</file>]]):format(unpack(fmts))
- end
- filelist = table.concat(filelist, "\n ")
- local com_msg = cia_commit_pattern:format(commit.sha:sub(1,7) .. suffix,
- filelist,
- author,
- logline)
- suffix = ""
- commits[#commits+1] = cia_pattern:format(project, branch,
- com_msg)
- end
- return commits
-end
-
-
-local cia_xmlrpc_pattern = [[
-<?xml version="1.0"?>
-<methodCall>
- <methodName>hub.deliver</methodName>
- <params>
- <value><string>%s</string></value>
- </params>
-</methodCall>
-]]
-
-local function send_to_cia(msg)
- -- By passing nil as the content-type we don't send a content-type
- -- header, which matches what we did before
- return http_post("cia.vc", "/RPC2",
- nil, cia_xmlrpc_pattern:format(util.html_escape(msg)))
-end
-
-local function cia_inform_commits(project, branch, repo, previoustip, newtip)
- repo = supple.unproxy_repo(repo)
- log.ddebug("Attempting CIA report for", branch, "in", project)
- log.ddebug("Previous tip was", previoustip, "new tip is", newtip)
- log.ddebug("Generating messages...")
- local msgs = cia_branch_update_gen(project, branch, repo,
- previoustip, newtip)
- log.ddebug("Generated", tostring(#msgs), "messages for CIA")
- local ok = 0
- for i = 1, #msgs do
- local msg = msgs[i]
- local code, msg, headers, content = send_to_cia(msg)
- if code == "200" then
- ok = ok + 1
- else
- log.warn("CIA returned", code,
- "processing message", tostring(i), "of", tostring(#msgs))
- print(content)
- break
- end
- end
- return ok == #msgs
-end
-
-local function set_hook_globals(config, repo, globs)
- for _, k in ipairs({ "table", "string", "pairs", "ipairs", "pcall",
- "xpcall", "unpack", "tostring", "tonumber", "math",
- "type", "coroutine", "select", "error", "assert" }) do
- globs[k] = _G[k]
- end
- local logcopy = {}
-
- for _, k in pairs({ "state", "crit", "critical", "err", "error", "warn",
- "warning", "chat", "info", "debug", "ddebug",
- "deepdebug" }) do
- logcopy[k] = log[k]
- end
- globs["log"] = logcopy
- globs["http_get"] = http_get
- globs["cia"] = { inform_commits = cia_inform_commits }
-end
-
local function set_supple_globals(action)
local globs = {}
local logcopy = {}
@@ -283,13 +112,11 @@ local function set_supple_globals(action)
if action == "post-receive" then
globs["http_get"] = http_get -- Legacy name for this, use http.get
globs["http"] = { get = http_get, post = http_post }
- globs["cia"] = { inform_commits = cia_inform_commits }
end
supple.set_globals(globs)
end
return {
update_actions = update_actions,
- set_hook_globals = set_hook_globals,
set_supple_globals = set_supple_globals,
}