liquid_feedback_frontend
diff config/_lf4rcs.lua @ 1656:3fb752f4afcb
Cleanup of configuration files
author | bsw |
---|---|
date | Sun Feb 14 12:46:39 2021 +0100 (2021-02-14) |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/config/_lf4rcs.lua Sun Feb 14 12:46:39 2021 +0100 1.3 @@ -0,0 +1,115 @@ 1.4 +-- Configuration of lf4rcs 1.5 +-- ------------------------------------------------------------------------ 1.6 +config.lf4rcs = {} 1.7 + 1.8 +-- Example configuration for controlling a Git repository 1.9 + 1.10 +config.lf4rcs.git = { 1.11 + 1.12 + render_draft_reference = function(url, draft) 1.13 + if not draft.external_reference then return end 1.14 + ui.tag{ content = _"Changeset:" } 1.15 + slot.put(" ") 1.16 + ui.link{ 1.17 + text = draft.external_reference, 1.18 + external = url .. ";a=commit;h=" .. draft.external_reference 1.19 + } 1.20 + end, 1.21 + 1.22 + get_remote_user = function() 1.23 + return os.getenv("REMOTE_USER") 1.24 + end, 1.25 + 1.26 + get_branches = function(path, exec) 1.27 + local branches = {} 1.28 + for line in io.lines() do 1.29 + local oldrev, newrev, branch = string.match(line, "([^ ]+) ([^ ]+) refs/heads/(.+)") 1.30 + if not branch then 1.31 + return nil, "unexpected format from git hook environment" 1.32 + end 1.33 + branches[branch] = { newrev } 1.34 + end 1.35 + return branches 1.36 + end, 1.37 + 1.38 + commit = function(path, exec, branch, target_node_id, close_message, merge_message) 1.39 + if merge_message then 1.40 + exec("git", "-C", path, "checkout", "-f", "master") 1.41 + exec("git", "-C", path, "merge", target_node_id, "-m", merge_message) 1.42 + exec("git", "-C", path, "push", "origin", "master") 1.43 + end 1.44 + end 1.45 + 1.46 +} 1.47 + 1.48 +-- Example configuration for controlling a Mercurial repository 1.49 +config.lf4rcs.hg = { 1.50 + 1.51 + working_branch_name = "work", 1.52 + 1.53 + render_draft_reference = function(url, draft) 1.54 + if not draft.external_reference then return end 1.55 + ui.tag{ content = _"Changeset graph:" } 1.56 + slot.put(" ") 1.57 + ui.link{ 1.58 + text = draft.external_reference, 1.59 + external = url .. "/graph/" .. draft.external_reference 1.60 + } 1.61 + end, 1.62 + 1.63 + get_remote_user = function() 1.64 + return os.getenv("REMOTE_USER") 1.65 + end, 1.66 + 1.67 + get_branches = function(path, exec) 1.68 + local first_node_id = os.getenv("HG_NODE") 1.69 + if not first_node_id then 1.70 + return nil, "internal error, no first node ID available" 1.71 + end 1.72 + local hg_log = exec( 1.73 + "hg", "log", "-R", path, "-r", first_node_id .. ":", "--template", "{branches}\n" 1.74 + ) 1.75 + local branches = {} 1.76 + for branch in hg_log:gmatch("(.-)\n") do 1.77 + if branch == "" then branch = "default" end 1.78 + if not branches[branch] then 1.79 + branches[branch] = {} 1.80 + local head_lines = exec( 1.81 + "hg", "heads", "-R", path, "--template", "{node}\n", branch 1.82 + ) 1.83 + for node_id in string.gmatch(head_lines, "[^\n]+") do 1.84 + table.insert(branches[branch], node_id) 1.85 + end 1.86 + end 1.87 + end 1.88 + return branches 1.89 + end, 1.90 + 1.91 + extra_checks = function(path, exec) 1.92 + local result = exec("hg", "heads", "-t", "-c") 1.93 + for branch in string.gmatch(result, "[^\n]+") do 1.94 + if branch == lf4rcs.config.hg.working_branch_name then 1.95 + return nil, "open head found for branch " .. lf4rcs.config.hg.working_branch_name 1.96 + end 1.97 + end 1.98 + return true 1.99 + end, 1.100 + 1.101 + commit = function(path, exec, branch, target_node_id, close_message, merge_message) 1.102 + exec("hg", "up", "-R", path, "-C", "-r", target_node_id) 1.103 + exec("hg", "commit", "-R", path, "--close-branch", "-m", close_message) 1.104 + if merge_message then 1.105 + exec("hg", "up", "-R", path, "-C", "-r", "default") 1.106 + exec("hg", "merge", "-R", path, "-r", "tip") 1.107 + exec("hg", "commit", "-R", path, "-m", merge_message) 1.108 + end 1.109 + end 1.110 + 1.111 +} 1.112 + 1.113 +-- Grace period after creating an initiative for pushing changes during verification phase 1.114 +-- disabled by default (nil), use PostgreSQL interval notation 1.115 +-- config.lf4rcs.push_grace_period = nil 1.116 + 1.117 +lf4rcs.init() 1.118 +