aboutsummaryrefslogtreecommitdiff
path: root/Src/external_dependencies/openmpt-trunk/include/premake/scripts/changes.lua
blob: 0d7b47916fb6e152ff248bfdcd0e66933b2cae10 (plain) (blame)
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
61
62
63
64
65
66
67
68
69
---
-- Output a list of merged PRs since last release in the CHANGES.txt format.
---

local usage = "Usage: premake5 --file=scripts/changes.lua --since=<rev> changes"

local sinceRev = _OPTIONS["since"]

if not sinceRev then
	print(usage)
	error("Missing `--since`", 0)
end


local function parsePullRequestId(line)
	return line:match("#%d+%s")
end

local function parseTitle(line)
	return line:match("||(.+)")
end

local function parseAuthor(line)
	return line:match("%s([^%s]-)/")
end

local function parseLog(line)
	local pr = parsePullRequestId(line)
	local title = parseTitle(line)
	local author = parseAuthor(line)
	return string.format("* PR %s %s (@%s)", pr, title, author)
end


local function gatherChanges()
	local cmd = string.format('git log HEAD "^%s" --merges --first-parent --format="%%s||%%b"', _OPTIONS["since"])
	local output = os.outputof(cmd)

	changes = {}

	for line in output:gmatch("[^\r\n]+") do
		table.insert(changes, parseLog(line))
	end

	return changes
end


local function generateChanges()
	local changes = gatherChanges()
	table.sort(changes)
	for i = 1, #changes do
		print(changes[i])
	end
end


newaction {
	trigger = "changes",
	description = "Generate list of git merges in CHANGES.txt format",
	execute = generateChanges
}

newoption {
	trigger = "since",
	value = "revision",
	description = "Log merges since this revision"
}