2017-01-10 14:12:52 +00:00
|
|
|
import argparse
|
|
|
|
import semver
|
|
|
|
import os
|
|
|
|
from subprocess import check_output
|
|
|
|
|
|
|
|
def main(argv=None):
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument('filenames', nargs='*')
|
|
|
|
args = parser.parse_args(argv)
|
|
|
|
branch_name = check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).strip().decode()
|
2017-02-02 03:30:31 +00:00
|
|
|
error = 1
|
2017-01-10 14:16:56 +00:00
|
|
|
for fn in args.filenames:
|
2017-02-02 03:30:31 +00:00
|
|
|
with open(fn) as f:
|
|
|
|
currentcontent = f.read().strip()
|
|
|
|
prevcontent = check_output(['git', 'show', 'HEAD:{}'.format(fn)]).strip().decode()
|
|
|
|
current = semver.parse_version_info(currentcontent)
|
|
|
|
print('Checking versions: {} -> {}'.format(prevcontent, currentcontent))
|
|
|
|
if (branch_name == 'master' and current.prerelease) or\
|
|
|
|
(semver.compare(currentcontent, prevcontent)<1):
|
|
|
|
return 1
|
|
|
|
else:
|
|
|
|
error = 0
|
|
|
|
return error
|
2017-01-10 14:16:56 +00:00
|
|
|
|
2017-01-10 14:12:52 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
exit(main())
|