rev |
line source |
bsw@1219
|
1 function lf4rcs.commit(issue)
|
bsw@1219
|
2 local repository, path, url = lf4rcs.get_config(issue.area.unit)
|
bsw@1219
|
3 if not (config.lf4rcs[repository] and config.lf4rcs[repository].commit) then
|
bsw@1219
|
4 error("Unsupported repository type")
|
bsw@1219
|
5 end
|
bsw@1219
|
6 local initiatives = Initiative:new_selector()
|
bsw@1219
|
7 :add_where{ "issue_id = ?", issue.id }
|
bsw@1219
|
8 :exec()
|
bsw@1219
|
9 for i, initiative in ipairs(initiatives) do
|
bsw@1219
|
10 local function exec(...)
|
bsw@1219
|
11 local command, output, err_message, exit_code = lf4rcs.exec(...)
|
bsw@1219
|
12 local log = "Executed: " .. command .. "\n"
|
bsw@1219
|
13 if output then
|
bsw@1219
|
14 log = log .. output .. "\n"
|
bsw@1219
|
15 end
|
bsw@1219
|
16 if err_message and #err_message > 0 then
|
bsw@1219
|
17 log = log .. "ERROR: " .. err_message .. "\n"
|
bsw@1219
|
18 end
|
bsw@1219
|
19 if exit_code and exit_code ~= 0 then
|
bsw@1219
|
20 log = log .. "Exit code: " .. tostring(exit_code) .. "\n"
|
bsw@1219
|
21 end
|
bsw@1219
|
22 issue.admin_notice = (issue.admin_notice or "") .. log
|
bsw@1219
|
23 issue:save()
|
bsw@1219
|
24 end
|
bsw@1219
|
25 local close_message, merge_message
|
bsw@1219
|
26 if initiative.winner then
|
bsw@1219
|
27 close_message = "Initiative i" .. initiative.id
|
bsw@1219
|
28 .. " accepted as winner. Closing branch."
|
bsw@1219
|
29 merge_message = "Initiative i" .. initiative.id
|
bsw@1219
|
30 .. " accepted as winner. Applying branch changesets to upstream."
|
bsw@1219
|
31 else
|
bsw@1219
|
32 close_message = "Initiative i" .. initiative.id .. " rejected. Closing branch."
|
bsw@1219
|
33 end
|
bsw@1219
|
34 local target_node_id = initiative.current_draft.external_reference
|
bsw@1219
|
35 if target_node_id then
|
bsw@1219
|
36 local branch = "i" .. initiative.id
|
bsw@1219
|
37 lf4rcs[repository].commit(path, exec, branch, target_node_id, close_message, merge_message)
|
bsw@1219
|
38 end
|
bsw@1219
|
39 end
|
bsw@1219
|
40 end
|