bsw@1219: function lf4rcs.commit(issue) bsw@1219: local repository, path, url = lf4rcs.get_config(issue.area.unit) bsw@1219: if not (config.lf4rcs[repository] and config.lf4rcs[repository].commit) then bsw@1219: error("Unsupported repository type") bsw@1219: end bsw@1219: local initiatives = Initiative:new_selector() bsw@1219: :add_where{ "issue_id = ?", issue.id } bsw@1219: :exec() bsw@1219: for i, initiative in ipairs(initiatives) do jbe@1220: local failure = false bsw@1219: local function exec(...) bsw@1219: local command, output, err_message, exit_code = lf4rcs.exec(...) jbe@1220: local log jbe@1220: if failure then jbe@1220: log = "Skipped: " .. command .. "\n" jbe@1220: else jbe@1220: log = "Executed: " .. command .. "\n" jbe@1220: if output then jbe@1220: log = log .. output .. "\n" jbe@1220: end jbe@1220: if err_message and #err_message > 0 then jbe@1220: log = log .. "ERROR: " .. err_message .. "\n" jbe@1220: failure = true jbe@1220: end jbe@1220: if exit_code and exit_code ~= 0 then jbe@1220: log = log .. "Exit code: " .. tostring(exit_code) .. "\n" jbe@1220: failure = true jbe@1220: end bsw@1219: end bsw@1219: issue.admin_notice = (issue.admin_notice or "") .. log bsw@1219: issue:save() bsw@1219: end bsw@1219: local close_message, merge_message bsw@1219: if initiative.winner then bsw@1219: close_message = "Initiative i" .. initiative.id bsw@1219: .. " accepted as winner. Closing branch." bsw@1219: merge_message = "Initiative i" .. initiative.id bsw@1219: .. " accepted as winner. Applying branch changesets to upstream." bsw@1219: else bsw@1219: close_message = "Initiative i" .. initiative.id .. " rejected. Closing branch." bsw@1219: end bsw@1219: local target_node_id = initiative.current_draft.external_reference bsw@1219: if target_node_id then bsw@1219: local branch = "i" .. initiative.id bsw/jbe@1309: config.lf4rcs[repository].commit(path, exec, branch, target_node_id, close_message, merge_message) bsw@1219: end bsw@1219: end bsw@1219: end