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