forked from WolfgangMehner/vim-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.lua
More file actions
158 lines (112 loc) · 3.75 KB
/
release.lua
File metadata and controls
158 lines (112 loc) · 3.75 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
--
--------------------------------------------------------------------------------
-- FILE: release.lua
-- USAGE: lua lua-support/release.lua <mode> [<options>]
-- DESCRIPTION: Run from the project's top-level directory.
-- OPTIONS: The mode is either "check", "zip", "cp-repo" or "help".
-- REQUIREMENTS: ---
-- BUGS: ---
-- NOTES: ---
-- AUTHOR: Wolfgang Mehner, <[email protected]>
-- COMPANY:
-- VERSION: 1.0
-- CREATED: 14.09.11
-- REVISION: 01.03.14
--------------------------------------------------------------------------------
--
function escape_shell ( text )
return string.gsub ( text, '[%(%);&=\' ]', function ( m ) return '\\' .. m end )
end ---------- end of function escape_shell ----------
local args = { ... }
local outfile = 'lua-support.zip'
local filelist = {
'autoload/mmtemplates/',
'autoload/mmtoolbox/make.vim',
'autoload/mmtoolbox/tools.vim',
'doc/luasupport.txt',
'doc/templatesupport.txt',
'doc/toolbox.txt',
'doc/toolboxmake.txt',
'ftplugin/lua.vim',
'plugin/lua-support.vim',
'lua-support/codesnippets/',
'lua-support/doc/',
'lua-support/rc/',
'lua-support/templates/',
'lua-support/README.md',
}
local filelist_repo = {
'lua-support/lua-doc/',
'lua-support/release.lua',
}
outfile = escape_shell ( outfile )
for idx, val in ipairs ( filelist ) do
filelist[ idx ] = escape_shell ( val )
end
local print_help = false
if #args == 0 then
print ( '\n=== failed: mode missing ===\n' )
print_help = true
elseif args[1] == 'check' then
local cmd = 'grep -nH ":[[:upper:]]\\+:\\|[Tt][Oo][Dd][Oo]" '..table.concat ( filelist, ' ' )
print ( '\n=== checking ===\n' )
local success, res_reason, res_status = os.execute ( cmd )
if success then
print ( '\n=== done ===\n' )
else
print ( '\n=== failed: '..res_reason..' '..res_status..' ===\n' )
end
elseif args[1] == 'zip' then
local cmd = 'zip -r '..outfile..' '..table.concat ( filelist, ' ' )
print ( '\n=== executing: '..outfile..' ===\n' )
local success, res_reason, res_status = os.execute ( cmd )
if success then
print ( '\n=== successful ===\n' )
else
print ( '\n=== failed: '..res_reason..' '..res_status..' ===\n' )
end
elseif args[1] == 'cp-repo' then
if #args >= 2 then
filelist_compl = {}
for key, val in pairs ( filelist ) do
table.insert ( filelist_compl, val )
end
for key, val in pairs ( filelist_repo ) do
table.insert ( filelist_compl, val )
end
os.execute ( 'mkdir -p '..args[2] )
local cmd = 'cp --parents -r '..table.concat ( filelist_compl, ' ' )..' '..args[2]
print ( '\n=== copying: '..args[2]..' ===\n' )
local success, res_reason, res_status = os.execute ( cmd )
if success then
cmd = 'cat lua-support/README.standalone.md lua-support/README.md > '..args[2]..'/README.md'
success, res_reason, res_status = os.execute ( cmd )
end
if success then
cmd = 'echo "\\ntaken from WolfgangMehner/vim-plugins, revision\\nhttps://github.com/WolfgangMehner/vim-plugins/commit/$(git rev-parse HEAD)" >> '..args[2]..'/project/commit.txt'
success, res_reason, res_status = os.execute ( cmd )
end
if success then
print ( '\n=== successful ===\n' )
else
print ( '\n=== failed: '..res_reason..' '..res_status..' ===\n' )
end
else
print ( '\n=== failed: no destination given: release.lua cp-repo <dest> ===\n' )
end
elseif args[1] == 'help' then
print_help = true
else
print ( '\n=== failed: unknown mode "'..args[1]..'" ===\n' )
print_help = true
end
if print_help then
print ( '' )
print ( 'release <mode>' )
print ( '' )
print ( '\tcheck - check the release' )
print ( '\tzip - create archive' )
print ( '\tcp-repo <dest> - copy the repository' )
print ( '\thelp - print help' )
print ( '' )
end