liquid_feedback_frontend

view config/_lf4rcs.lua @ 1668:6d75df24e66e

Updated German translation
author bsw
date Sun Mar 07 09:52:36 2021 +0100 (2021-03-07)
parents 3fb752f4afcb
children
line source
1 -- Configuration of lf4rcs
2 -- ------------------------------------------------------------------------
3 config.lf4rcs = {}
5 -- Example configuration for controlling a Git repository
7 config.lf4rcs.git = {
9 render_draft_reference = function(url, draft)
10 if not draft.external_reference then return end
11 ui.tag{ content = _"Changeset:" }
12 slot.put(" ")
13 ui.link{
14 text = draft.external_reference,
15 external = url .. ";a=commit;h=" .. draft.external_reference
16 }
17 end,
19 get_remote_user = function()
20 return os.getenv("REMOTE_USER")
21 end,
23 get_branches = function(path, exec)
24 local branches = {}
25 for line in io.lines() do
26 local oldrev, newrev, branch = string.match(line, "([^ ]+) ([^ ]+) refs/heads/(.+)")
27 if not branch then
28 return nil, "unexpected format from git hook environment"
29 end
30 branches[branch] = { newrev }
31 end
32 return branches
33 end,
35 commit = function(path, exec, branch, target_node_id, close_message, merge_message)
36 if merge_message then
37 exec("git", "-C", path, "checkout", "-f", "master")
38 exec("git", "-C", path, "merge", target_node_id, "-m", merge_message)
39 exec("git", "-C", path, "push", "origin", "master")
40 end
41 end
43 }
45 -- Example configuration for controlling a Mercurial repository
46 config.lf4rcs.hg = {
48 working_branch_name = "work",
50 render_draft_reference = function(url, draft)
51 if not draft.external_reference then return end
52 ui.tag{ content = _"Changeset graph:" }
53 slot.put(" ")
54 ui.link{
55 text = draft.external_reference,
56 external = url .. "/graph/" .. draft.external_reference
57 }
58 end,
60 get_remote_user = function()
61 return os.getenv("REMOTE_USER")
62 end,
64 get_branches = function(path, exec)
65 local first_node_id = os.getenv("HG_NODE")
66 if not first_node_id then
67 return nil, "internal error, no first node ID available"
68 end
69 local hg_log = exec(
70 "hg", "log", "-R", path, "-r", first_node_id .. ":", "--template", "{branches}\n"
71 )
72 local branches = {}
73 for branch in hg_log:gmatch("(.-)\n") do
74 if branch == "" then branch = "default" end
75 if not branches[branch] then
76 branches[branch] = {}
77 local head_lines = exec(
78 "hg", "heads", "-R", path, "--template", "{node}\n", branch
79 )
80 for node_id in string.gmatch(head_lines, "[^\n]+") do
81 table.insert(branches[branch], node_id)
82 end
83 end
84 end
85 return branches
86 end,
88 extra_checks = function(path, exec)
89 local result = exec("hg", "heads", "-t", "-c")
90 for branch in string.gmatch(result, "[^\n]+") do
91 if branch == lf4rcs.config.hg.working_branch_name then
92 return nil, "open head found for branch " .. lf4rcs.config.hg.working_branch_name
93 end
94 end
95 return true
96 end,
98 commit = function(path, exec, branch, target_node_id, close_message, merge_message)
99 exec("hg", "up", "-R", path, "-C", "-r", target_node_id)
100 exec("hg", "commit", "-R", path, "--close-branch", "-m", close_message)
101 if merge_message then
102 exec("hg", "up", "-R", path, "-C", "-r", "default")
103 exec("hg", "merge", "-R", path, "-r", "tip")
104 exec("hg", "commit", "-R", path, "-m", merge_message)
105 end
106 end
108 }
110 -- Grace period after creating an initiative for pushing changes during verification phase
111 -- disabled by default (nil), use PostgreSQL interval notation
112 -- config.lf4rcs.push_grace_period = nil
114 lf4rcs.init()

Impressum / About Us