-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathversion-check
More file actions
executable file
·49 lines (41 loc) · 1.14 KB
/
version-check
File metadata and controls
executable file
·49 lines (41 loc) · 1.14 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
#! /usr/bin/env lua
local io, os = require('io'), require('os')
local function match(pattern, file) -- {{{
for line in io.lines(file) do
local _, _, found = line:find(pattern)
if found then
return found
end
end
end -- }}}
local function resolve(pats) -- {{{
local same = true
local first = nil
local found = {}
for _, pat in ipairs(pats) do
local got = match(pat.pattern, pat.file)
if not first then
first = got
elseif first ~= got then
same = false
end
found[pat.name] = got
end
return found, same
end -- }}}
local pats = {
{name='Readme', file='README.markdown', pattern='Version:%s*%*([^%*]*)%*'},
{name='Plugin', file='plugin/systemate.vim', pattern='g:systemate_version%s*=%s*\'([^\']*)\''},
{name='Addon', file='addon-info.json', pattern='"version":%s*"([^"]*)"'},
{name='Documentation', file='doc/systemate.txt', pattern='VERSION:%s*(%S*)'},
{name='Comment', file='plugin/systemate.vim', pattern='VERSION:%s*(%S*)'},
}
local found, same = resolve(pats)
if not same then
print('Version mismatch!')
for name, value in pairs(found) do
print(string.format('\t%s: %s', name, value))
end
os.exit(1)
end
os.exit(0)