mirror of
https://github.com/JimmXinu/FanFicFare.git
synced 2026-05-03 04:14:35 +02:00
Update version updater to be more automatic.
This commit is contained in:
parent
9c43667b44
commit
3301b96390
1 changed files with 32 additions and 15 deletions
|
|
@ -51,8 +51,28 @@ version="2.3.6"
|
|||
r'(?P<minor>[0-9]+)(?P<dot2>[, \\.-]+)' \
|
||||
r'(?P<micro>[0-9]+[a-z]?)(?P<suffix>[",\\)]*\r?\n)$'
|
||||
|
||||
version_subs = r'\g<prefix>version\g<infix>%s\g<dot1>%s\g<dot2>%s\g<suffix>' % tuple(args)
|
||||
|
||||
flag = args[0]
|
||||
|
||||
if len(args) > 1 :
|
||||
version = [int(x) for x in args[1:]]
|
||||
else:
|
||||
with codecs.open(version_files[0], 'r', 'utf-8') as source_file:
|
||||
for line in source_file:
|
||||
m = re.match(version_re,line)
|
||||
if m:
|
||||
prior_version = (m.group('major'),m.group('minor'),m.group('micro'))
|
||||
print(prior_version)
|
||||
break
|
||||
version = [int(x) for x in prior_version]
|
||||
if flag == 'test':
|
||||
version[2] += 1
|
||||
if flag == 'release':
|
||||
version[1] += 1
|
||||
version[2] = 0
|
||||
|
||||
print(version)
|
||||
version_subs = r'\g<prefix>version\g<infix>%s\g<dot1>%s\g<dot2>%s\g<suffix>' % tuple(version)
|
||||
|
||||
do_loop(version_files, version_re, version_subs)
|
||||
|
||||
index_files = []
|
||||
|
|
@ -63,11 +83,9 @@ version="2.3.6"
|
|||
# index_subs = 'https://%s-%s-0.fanficfare.appspot.com'%saved_version[0:2]
|
||||
# do_loop(index_files, index_re, index_subs)
|
||||
|
||||
release = 'Release'
|
||||
if int(args[-1]) > 0:
|
||||
release = 'Test'
|
||||
release = flag.capitalize()
|
||||
print('\ngit add %s'%(" ".join(version_files+index_files)))
|
||||
print('git commit -m "Bump %s Version %s"'%(release,'.'.join(args)))
|
||||
print('git commit -m "Bump %s Version %s"'%(release,'.'.join([str(x) for x in version])))
|
||||
|
||||
def do_loop(files, pattern, substring):
|
||||
global saved_version
|
||||
|
|
@ -88,13 +106,12 @@ def do_loop(files, pattern, substring):
|
|||
rename(target_file_path,source_file_path)
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = sys.argv[1:]
|
||||
try:
|
||||
if len(args) != 3:
|
||||
raise Exception()
|
||||
[int(x) for x in args]
|
||||
except:
|
||||
print("Requires exactly 3 numeric args: major minor micro")
|
||||
exit()
|
||||
main(args)
|
||||
args = list(sys.argv[1:])
|
||||
|
||||
if len(args) == 0:
|
||||
args.append('test')
|
||||
if args[0] in ('test', 'release') and len(args) in (1,4):
|
||||
main(args)
|
||||
else:
|
||||
print("args: (test|release) [1 2 3]")
|
||||
# print(saved_version)
|
||||
|
|
|
|||
Loading…
Reference in a new issue