@@ -11,9 +11,12 @@ local function populate_section(content, name, list)
11
11
)
12
12
content [# content + 1 ] = ' '
13
13
end
14
- local function generate_changelog ()
15
- local latest_tag = vim .fn .system (' git describe --tags `git rev-list --tags --max-count=1`' ):gsub (' \n ' , ' ' )
16
- local commits = vim .fn .systemlist (' git log ' .. latest_tag .. " ..master --pretty=format:'%s'" )
14
+
15
+ local function get_changes (latest_tag )
16
+ if not latest_tag then
17
+ latest_tag = vim .fn .system (' git describe --tags `git rev-list --tags --max-count=1`' ):gsub (' \n ' , ' ' )
18
+ end
19
+ local commits = vim .fn .systemlist (' git log ' .. latest_tag .. " ..feat/changelog --pretty=format:'%s'" )
17
20
local fixes = {}
18
21
local features = {}
19
22
local breaking_changes = {}
@@ -32,26 +35,40 @@ local function generate_changelog()
32
35
end
33
36
end
34
37
end
38
+ local content = {}
39
+
40
+ populate_section (content , ' Breaking changes' , breaking_changes )
41
+ populate_section (content , ' Features' , features )
42
+ populate_section (content , ' Bug fixes' , fixes )
43
+
44
+ return content
45
+ end
46
+
47
+ local function generate_changelog ()
48
+ local latest_tag = vim .fn .system (' git describe --tags `git rev-list --tags --max-count=1`' ):gsub (' \n ' , ' ' )
35
49
local new_tag = arg [1 ]
36
- local changelog = vim .fn .readfile (' ./docs/changelog.org' )
37
- local start = { unpack (changelog , 1 , 2 ) }
38
- local remaining = { unpack (changelog , 3 ) }
39
50
40
51
local new_content = {
41
52
' ** ' .. new_tag ,
42
53
' - Date: [[' .. os.date (' %Y-%m-%d' ) .. ' ]]' ,
43
54
(' - [[https://github.com/nvim-orgmode/orgmode/compare/%s...%s][Compare]]' ):format (latest_tag , new_tag ),
44
- (' - [[https://github.com/nvim-orgmode/orgmode/releases/tag/%s][Link to release]]' ):format (latest_tag ),
55
+ (' - [[https://github.com/nvim-orgmode/orgmode/releases/tag/%s][Link to release]]' ):format (new_tag ),
45
56
' ' ,
46
57
}
47
- populate_section (new_content , ' Breaking changes' , breaking_changes )
48
- populate_section (new_content , ' Features' , features )
49
- populate_section (new_content , ' Bug fixes' , fixes )
58
+ vim .list_extend (new_content , get_changes (latest_tag ))
59
+
60
+ local changelog = vim .fn .readfile (' ./docs/changelog.org' )
61
+ local start = { unpack (changelog , 1 , 2 ) }
62
+ local remaining = { unpack (changelog , 3 ) }
50
63
51
64
local new_changelog = vim .list_extend (start , new_content )
52
65
new_changelog = vim .list_extend (new_changelog , remaining )
53
66
54
67
vim .fn .writefile (new_changelog , ' ./docs/changelog.org' )
55
68
end
56
69
70
+ if arg [2 ] and arg [2 ] == ' print' then
71
+ return io.write (table.concat (get_changes (), ' \n ' ))
72
+ end
73
+
57
74
generate_changelog ()
0 commit comments