1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
return {
["CHANGES.md"] = function(version, content)
-- either replace the first line with the concrete release number or
-- add an "upcoming" line, depending on the given version string
local current_first_line = content:match("^([^\n]*)\n") or ""
local current_version = current_first_line:match("%d+%.%d+%.%d+")
local pure_version = version:match("%d+%.%d+%.%d+")
local format_string
if current_version == nil or current_version == pure_version then
-- if the current version is an upcoming version, or if both pure
-- versions are the same, replace the first line
format_string = "%s\n%s"
content = content:gsub("^[^\n]*\n", "", 1)
else
-- otherwise, prepend a new line
format_string = "%s\n\n%s"
end
local first_line
if version:find("%-SNAPSHOT$") then
-- if the new version is a snapshot, use an "upcoming" header
first_line = "# Changes since latest release"
else
-- otherwise use the concrete version
first_line = "# Changes in " .. version
end
return (format_string):format(first_line, content)
end,
["Cargo.toml"] = function(version, content)
-- replace the first "version" attribute, which is most likely our
-- own, with the current version string
content = content:gsub(
'version = %b""', ('version = "%s"'):format(version), 1
)
local post_func = function()
-- run `cargo check` on the current package, which will then also
-- update Cargo.lock with the new version string
local pkgid
do
local process = io.popen("cargo pkgid")
pkgid = process:read("a")
process:close()
end
os.execute(("cargo check -p %q"):format(pkgid))
end
return content, {post_func = post_func}
end,
VERSION = function(version)
return version
end
}