liquid_feedback_frontend

diff env/lf4rcs/commit.lua @ 1219:30523f31b186

Added lf4rcs module and example configuration
author bsw
date Mon Nov 30 19:40:38 2015 +0100 (2015-11-30)
parents
children af42478acf74
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/env/lf4rcs/commit.lua	Mon Nov 30 19:40:38 2015 +0100
     1.3 @@ -0,0 +1,40 @@
     1.4 +function lf4rcs.commit(issue)
     1.5 +  local repository, path, url = lf4rcs.get_config(issue.area.unit)
     1.6 +  if not (config.lf4rcs[repository] and config.lf4rcs[repository].commit) then
     1.7 +    error("Unsupported repository type")
     1.8 +  end
     1.9 +  local initiatives = Initiative:new_selector()
    1.10 +    :add_where{ "issue_id = ?", issue.id }
    1.11 +    :exec()
    1.12 +  for i, initiative in ipairs(initiatives) do
    1.13 +    local function exec(...)
    1.14 +      local command, output, err_message, exit_code = lf4rcs.exec(...)
    1.15 +      local log = "Executed: " .. command .. "\n"
    1.16 +      if output then
    1.17 +        log = log .. output .. "\n"
    1.18 +      end
    1.19 +      if err_message and #err_message > 0 then
    1.20 +        log = log .. "ERROR: " .. err_message .. "\n"
    1.21 +      end
    1.22 +      if exit_code and exit_code ~= 0 then
    1.23 +        log = log .. "Exit code: " .. tostring(exit_code) .. "\n"
    1.24 +      end
    1.25 +      issue.admin_notice = (issue.admin_notice or "") .. log
    1.26 +      issue:save()
    1.27 +    end
    1.28 +    local close_message, merge_message
    1.29 +    if initiative.winner then
    1.30 +      close_message = "Initiative i" .. initiative.id
    1.31 +                      .. " accepted as winner. Closing branch."
    1.32 +      merge_message = "Initiative i" .. initiative.id 
    1.33 +                      .. " accepted as winner. Applying branch changesets to upstream."
    1.34 +    else
    1.35 +      close_message = "Initiative i" .. initiative.id .. " rejected. Closing branch."
    1.36 +    end
    1.37 +    local target_node_id = initiative.current_draft.external_reference
    1.38 +    if target_node_id then
    1.39 +      local branch = "i" .. initiative.id
    1.40 +      lf4rcs[repository].commit(path, exec, branch, target_node_id, close_message, merge_message)
    1.41 +    end
    1.42 +  end
    1.43 +end

Impressum / About Us