| 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 | 
| jbe@1220 | 10     local failure = false | 
| bsw@1219 | 11     local function exec(...) | 
| bsw@1219 | 12       local command, output, err_message, exit_code = lf4rcs.exec(...) | 
| jbe@1220 | 13       local log | 
| jbe@1220 | 14       if failure then | 
| jbe@1220 | 15         log = "Skipped: " .. command .. "\n" | 
| jbe@1220 | 16       else | 
| jbe@1220 | 17         log = "Executed: " .. command .. "\n" | 
| jbe@1220 | 18         if output then | 
| jbe@1220 | 19           log = log .. output .. "\n" | 
| jbe@1220 | 20         end | 
| jbe@1220 | 21         if err_message and #err_message > 0 then | 
| jbe@1220 | 22           log = log .. "ERROR: " .. err_message .. "\n" | 
| jbe@1220 | 23           failure = true | 
| jbe@1220 | 24         end | 
| jbe@1220 | 25         if exit_code and exit_code ~= 0 then | 
| jbe@1220 | 26           log = log .. "Exit code: " .. tostring(exit_code) .. "\n" | 
| jbe@1220 | 27           failure = true | 
| jbe@1220 | 28         end | 
| bsw@1219 | 29       end | 
| bsw@1219 | 30       issue.admin_notice = (issue.admin_notice or "") .. log | 
| bsw@1219 | 31       issue:save() | 
| bsw@1219 | 32     end | 
| bsw@1219 | 33     local close_message, merge_message | 
| bsw@1219 | 34     if initiative.winner then | 
| bsw@1219 | 35       close_message = "Initiative i" .. initiative.id | 
| bsw@1219 | 36                       .. " accepted as winner. Closing branch." | 
| bsw@1219 | 37       merge_message = "Initiative i" .. initiative.id | 
| bsw@1219 | 38                       .. " accepted as winner. Applying branch changesets to upstream." | 
| bsw@1219 | 39     else | 
| bsw@1219 | 40       close_message = "Initiative i" .. initiative.id .. " rejected. Closing branch." | 
| bsw@1219 | 41     end | 
| bsw@1219 | 42     local target_node_id = initiative.current_draft.external_reference | 
| bsw@1219 | 43     if target_node_id then | 
| bsw@1219 | 44       local branch = "i" .. initiative.id | 
| bsw/jbe@1309 | 45       config.lf4rcs[repository].commit(path, exec, branch, target_node_id, close_message, merge_message) | 
| bsw@1219 | 46     end | 
| bsw@1219 | 47   end | 
| bsw@1219 | 48 end |