liquid_feedback_frontend

view env/lf4rcs/commit.lua @ 1309:32cc544d5a5b

Cumulative patch for upcoming frontend version 4
author bsw/jbe
date Sun Jul 15 14:07:29 2018 +0200 (2018-07-15)
parents af42478acf74
children
line source
1 function lf4rcs.commit(issue)
2 local repository, path, url = lf4rcs.get_config(issue.area.unit)
3 if not (config.lf4rcs[repository] and config.lf4rcs[repository].commit) then
4 error("Unsupported repository type")
5 end
6 local initiatives = Initiative:new_selector()
7 :add_where{ "issue_id = ?", issue.id }
8 :exec()
9 for i, initiative in ipairs(initiatives) do
10 local failure = false
11 local function exec(...)
12 local command, output, err_message, exit_code = lf4rcs.exec(...)
13 local log
14 if failure then
15 log = "Skipped: " .. command .. "\n"
16 else
17 log = "Executed: " .. command .. "\n"
18 if output then
19 log = log .. output .. "\n"
20 end
21 if err_message and #err_message > 0 then
22 log = log .. "ERROR: " .. err_message .. "\n"
23 failure = true
24 end
25 if exit_code and exit_code ~= 0 then
26 log = log .. "Exit code: " .. tostring(exit_code) .. "\n"
27 failure = true
28 end
29 end
30 issue.admin_notice = (issue.admin_notice or "") .. log
31 issue:save()
32 end
33 local close_message, merge_message
34 if initiative.winner then
35 close_message = "Initiative i" .. initiative.id
36 .. " accepted as winner. Closing branch."
37 merge_message = "Initiative i" .. initiative.id
38 .. " accepted as winner. Applying branch changesets to upstream."
39 else
40 close_message = "Initiative i" .. initiative.id .. " rejected. Closing branch."
41 end
42 local target_node_id = initiative.current_draft.external_reference
43 if target_node_id then
44 local branch = "i" .. initiative.id
45 config.lf4rcs[repository].commit(path, exec, branch, target_node_id, close_message, merge_message)
46 end
47 end
48 end

Impressum / About Us