mirror of
https://github.com/vale981/tdesktop
synced 2025-03-05 17:51:41 -05:00
Improve updates sending script.
This commit is contained in:
parent
e5536880fb
commit
6fc4facddf
1 changed files with 75 additions and 49 deletions
|
@ -8,6 +8,7 @@ today = ''
|
||||||
nextLast = False
|
nextLast = False
|
||||||
nextDate = False
|
nextDate = False
|
||||||
building = True
|
building = True
|
||||||
|
composing = False
|
||||||
for arg in sys.argv:
|
for arg in sys.argv:
|
||||||
if nextLast:
|
if nextLast:
|
||||||
lastCommit = arg
|
lastCommit = arg
|
||||||
|
@ -17,8 +18,11 @@ for arg in sys.argv:
|
||||||
nextDate = False
|
nextDate = False
|
||||||
elif arg == 'send':
|
elif arg == 'send':
|
||||||
building = False
|
building = False
|
||||||
|
composing = False
|
||||||
elif arg == 'from':
|
elif arg == 'from':
|
||||||
nextLast = True
|
nextLast = True
|
||||||
|
building = False
|
||||||
|
composing = True
|
||||||
elif arg == 'date':
|
elif arg == 'date':
|
||||||
nextDate = True
|
nextDate = True
|
||||||
|
|
||||||
|
@ -103,60 +107,82 @@ if building:
|
||||||
print('Finished.')
|
print('Finished.')
|
||||||
finish(0)
|
finish(0)
|
||||||
|
|
||||||
|
if composing:
|
||||||
|
templatePath = scriptPath + '/../../../TelegramPrivate/updates_template.txt'
|
||||||
|
if not os.path.exists(templatePath):
|
||||||
|
print('[ERROR] Template file "' + templatePath + '" not found.')
|
||||||
|
finish(1)
|
||||||
|
|
||||||
|
if not re.match(r'^[a-f0-9]{40}$', lastCommit):
|
||||||
|
print('[ERROR] Wrong last commit: ' + lastCommit)
|
||||||
|
finish(1)
|
||||||
|
|
||||||
|
log = subprocess.check_output(['git', 'log', lastCommit+'..HEAD'])
|
||||||
|
logLines = log.split('\n')
|
||||||
|
firstCommit = ''
|
||||||
|
commits = []
|
||||||
|
for line in logLines:
|
||||||
|
if line.startswith('commit '):
|
||||||
|
commit = line.split(' ')[1]
|
||||||
|
if not len(firstCommit):
|
||||||
|
firstCommit = commit
|
||||||
|
commits.append('')
|
||||||
|
elif line.startswith(' '):
|
||||||
|
stripped = line[4:]
|
||||||
|
if not len(stripped):
|
||||||
|
continue
|
||||||
|
elif not len(commits):
|
||||||
|
print('[ERROR] Bad git log output:')
|
||||||
|
print(log)
|
||||||
|
finish(1)
|
||||||
|
if len(commits[len(commits) - 1]):
|
||||||
|
commits[len(commits) - 1] += '\n' + stripped
|
||||||
|
else:
|
||||||
|
commits[len(commits) - 1] = '- ' + stripped
|
||||||
|
commits.reverse()
|
||||||
|
if not len(commits):
|
||||||
|
print('[ERROR] No commits since last build :(')
|
||||||
|
finish(1)
|
||||||
|
|
||||||
|
changelog = '\n'.join(commits)
|
||||||
|
print('\n\nReady! File: ' + archive + '\nChangelog:\n' + changelog)
|
||||||
|
with open(templatePath, 'r') as template:
|
||||||
|
with open(scriptPath + '/../../out/Debug/' + outputFolder + '/command.txt', 'w') as f:
|
||||||
|
for line in template:
|
||||||
|
if line.startswith('//'):
|
||||||
|
continue
|
||||||
|
line = line.replace('{path}', scriptPath + '/../../out/Debug/' + outputFolder + '/' + archive)
|
||||||
|
line = line.replace('{caption}', 'TDesktop at ' + today.replace('_', '.') + ':\n\n' + changelog)
|
||||||
|
f.write(line)
|
||||||
|
finish(0)
|
||||||
|
|
||||||
|
commandPath = scriptPath + '/../../out/Debug/' + outputFolder + '/command.txt'
|
||||||
|
if not os.path.exists(commandPath):
|
||||||
|
print('[ERROR] Command file not found.')
|
||||||
|
finish(1)
|
||||||
|
|
||||||
|
readingCaption = False
|
||||||
|
caption = ''
|
||||||
|
with open(commandPath, 'r') as f:
|
||||||
|
for line in f:
|
||||||
|
if readingCaption:
|
||||||
|
caption = caption + line
|
||||||
|
elif line.startswith('caption: '):
|
||||||
|
readingCaption = True
|
||||||
|
caption = line[len('caption: '):]
|
||||||
|
if not caption.startswith('TDesktop at ' + today.replace('_', '.') + ':'):
|
||||||
|
print('[ERROR] Wrong caption start.')
|
||||||
|
finish(1)
|
||||||
|
print('\n\nSending! File: ' + archive + '\nChangelog:\n' + caption)
|
||||||
|
if len(caption) > 1024:
|
||||||
|
print('[ERROR] Length: ' + str(len(caption)))
|
||||||
|
print('vi ' + commandPath)
|
||||||
|
finish(1)
|
||||||
|
|
||||||
if not os.path.exists('../out/Debug/' + outputFolder + '/' + archive):
|
if not os.path.exists('../out/Debug/' + outputFolder + '/' + archive):
|
||||||
print('[ERROR] Not built yet.')
|
print('[ERROR] Not built yet.')
|
||||||
finish(1)
|
finish(1)
|
||||||
|
|
||||||
templatePath = scriptPath + '/../../../TelegramPrivate/updates_template.txt'
|
|
||||||
if not os.path.exists(templatePath):
|
|
||||||
print('[ERROR] Template file "' + templatePath + '" not found.')
|
|
||||||
finish(1)
|
|
||||||
|
|
||||||
if not re.match(r'^[a-f0-9]{40}$', lastCommit):
|
|
||||||
print('[ERROR] Wrong last commit: ' + lastCommit)
|
|
||||||
finish(1)
|
|
||||||
|
|
||||||
log = subprocess.check_output(['git', 'log', lastCommit+'..HEAD'])
|
|
||||||
logLines = log.split('\n')
|
|
||||||
firstCommit = ''
|
|
||||||
commits = []
|
|
||||||
for line in logLines:
|
|
||||||
if line.startswith('commit '):
|
|
||||||
commit = line.split(' ')[1]
|
|
||||||
if not len(firstCommit):
|
|
||||||
firstCommit = commit
|
|
||||||
commits.append('')
|
|
||||||
elif line.startswith(' '):
|
|
||||||
stripped = line[4:]
|
|
||||||
if not len(stripped):
|
|
||||||
continue
|
|
||||||
elif not len(commits):
|
|
||||||
print('[ERROR] Bad git log output:')
|
|
||||||
print(log)
|
|
||||||
finish(1)
|
|
||||||
if len(commits[len(commits) - 1]):
|
|
||||||
commits[len(commits) - 1] += '\n' + stripped
|
|
||||||
else:
|
|
||||||
commits[len(commits) - 1] = '- ' + stripped
|
|
||||||
commits.reverse()
|
|
||||||
if not len(commits):
|
|
||||||
print('[ERROR] No commits since last build :(')
|
|
||||||
finish(1)
|
|
||||||
|
|
||||||
changelog = '\n'.join(commits)
|
|
||||||
print('\n\nReady! File: ' + archive + '\nChangelog:\n' + changelog)
|
|
||||||
if len(changelog) > 1024:
|
|
||||||
print('[ERROR] Length: ' + str(len(changelog)))
|
|
||||||
finish(1)
|
|
||||||
with open(templatePath, 'r') as template:
|
|
||||||
with open(scriptPath + '/../../out/Debug/' + outputFolder + '/command.txt', 'w') as f:
|
|
||||||
for line in template:
|
|
||||||
if line.startswith('//'):
|
|
||||||
continue
|
|
||||||
line = line.replace('{path}', scriptPath + '/../../out/Debug/' + outputFolder + '/' + archive)
|
|
||||||
line = line.replace('{caption}', 'TDesktop at ' + today.replace('_', '.') + ':\n\n' + changelog)
|
|
||||||
f.write(line)
|
|
||||||
subprocess.call(scriptPath + '/../../out/Debug/Telegram.app/Contents/MacOS/Telegram -sendpath interpret://' + scriptPath + '/../../out/Debug/' + outputFolder + '/command.txt', shell=True)
|
subprocess.call(scriptPath + '/../../out/Debug/Telegram.app/Contents/MacOS/Telegram -sendpath interpret://' + scriptPath + '/../../out/Debug/' + outputFolder + '/command.txt', shell=True)
|
||||||
|
|
||||||
finish(0)
|
finish(0)
|
||||||
|
|
Loading…
Add table
Reference in a new issue