47 lines
1.3 KiB
Python
47 lines
1.3 KiB
Python
import subprocess
|
|
|
|
def pullTags():
|
|
result = subprocess.run(['git', 'fetch', '--tags'], stdout=subprocess.PIPE)
|
|
|
|
def getCurrentTag():
|
|
result = subprocess.run(['git', 'rev-parse', 'HEAD'], stdout=subprocess.PIPE)
|
|
result = result.stdout.decode('utf-8')[:-1]
|
|
|
|
result = subprocess.run(['git', 'name-rev', '--tags', '--name-only', result], stdout=subprocess.PIPE)
|
|
result = result.stdout.decode('utf-8')[:-1]
|
|
|
|
return result
|
|
|
|
def checkTag():
|
|
pullTags()
|
|
|
|
result = subprocess.run(['git', 'tag'], stdout=subprocess.PIPE)
|
|
result = result.stdout.decode('utf-8')[:-1].split('\n')
|
|
|
|
latest_tag = getCurrentTag()
|
|
|
|
for tag in result:
|
|
if float(tag[1:]) > float(latest_tag[1:]):
|
|
latest_tag = tag
|
|
|
|
return latest_tag
|
|
|
|
def update(recursive=False):
|
|
current_tag = getCurrentTag()
|
|
latest_tag = checkTag()
|
|
|
|
if recursive:
|
|
print(current_tag, latest_tag)
|
|
|
|
if current_tag != latest_tag:
|
|
print("update")
|
|
result = subprocess.run(['git', 'checkout', latest_tag], stdout=subprocess.PIPE)
|
|
update(recursive=True)
|
|
else:
|
|
print("no update nessesary")
|
|
|
|
result = subprocess.run(['systemctl', 'restart', 'hardware-monitor.service'], stdout=subprocess.PIPE)
|
|
|
|
if __name__ == "__main__":
|
|
update()
|