Added repo Git info: version.tag (single deterministic tag), version.tags (all tags pointing to head).
Fixed handling of paths with spaces.pull/63/head
parent
07ba94e47e
commit
86ce2703c4
|
|
@ -245,15 +245,20 @@ def get_libs():
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def run_git_command(cmd_args: list, cwd: str = None):
|
||||||
|
try:
|
||||||
|
res = subprocess.run(cmd_args, stdout = subprocess.PIPE, stderr = subprocess.PIPE, cwd = cwd, check=True)
|
||||||
|
return res.stdout.decode(encoding = 'utf8', errors='ignore').strip() if len(res.stdout) > 0 else ''
|
||||||
|
except Exception:
|
||||||
|
return ''
|
||||||
|
|
||||||
|
|
||||||
def get_repos():
|
def get_repos():
|
||||||
try:
|
try:
|
||||||
repos = {}
|
repos = {}
|
||||||
for key, val in paths.paths.items():
|
for key, val in paths.paths.items():
|
||||||
try:
|
try:
|
||||||
cmd = f'git -C {val} log --pretty=format:"%h %ad" -1 --date=short'
|
words = run_git_command(['git', 'log', '--pretty=format:%h %ad', '-1', '--date=short'], cwd=val).split(' ')
|
||||||
res = subprocess.run(f'{cmd} {val}', stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell=True, check=True)
|
|
||||||
stdout = res.stdout.decode(encoding = 'utf8', errors='ignore') if len(res.stdout) > 0 else ''
|
|
||||||
words = stdout.split(' ')
|
|
||||||
repos[key] = f'[{words[0]}] {words[1]}'
|
repos[key] = f'[{words[0]}] {words[1]}'
|
||||||
except Exception:
|
except Exception:
|
||||||
repos[key] = '(unknown)'
|
repos[key] = '(unknown)'
|
||||||
|
|
@ -293,21 +298,21 @@ def get_torch():
|
||||||
def get_version():
|
def get_version():
|
||||||
version = {}
|
version = {}
|
||||||
try:
|
try:
|
||||||
res = subprocess.run('git log --pretty=format:"%h %ad" -1 --date=short', stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell=True, check=True)
|
githash, updated = run_git_command(['git', 'log', '--pretty=format:%h %ad', '-1', '--date=short']).split(' ')
|
||||||
ver = res.stdout.decode(encoding = 'utf8', errors='ignore') if len(res.stdout) > 0 else ''
|
tag = run_git_command(['git', 'describe', '--tags', '--exact-match'])
|
||||||
githash, updated = ver.split(' ')
|
tags = " ".join(run_git_command(['git', 'tag', '--points-at', 'HEAD']).split())
|
||||||
res = subprocess.run('git remote get-url origin', stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell=True, check=True)
|
origin = run_git_command(['git', 'remote', 'get-url', 'origin'])
|
||||||
origin = res.stdout.decode(encoding = 'utf8', errors='ignore') if len(res.stdout) > 0 else ''
|
branch = run_git_command(['git', 'rev-parse', '--abbrev-ref', 'HEAD'])
|
||||||
res = subprocess.run('git rev-parse --abbrev-ref HEAD', stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell=True, check=True)
|
url = origin.removesuffix('.git') + '/tree/' + branch
|
||||||
branch = res.stdout.decode(encoding = 'utf8', errors='ignore') if len(res.stdout) > 0 else ''
|
app = origin.split('/')[-1]
|
||||||
url = origin.replace('\n', '').removesuffix('.git') + '/tree/' + branch.replace('\n', '')
|
|
||||||
app = origin.replace('\n', '').split('/')[-1]
|
|
||||||
if app == 'automatic':
|
if app == 'automatic':
|
||||||
app = 'SD.next'
|
app = 'SD.next'
|
||||||
version = {
|
version = {
|
||||||
'app': app,
|
'app': app,
|
||||||
'updated': updated,
|
'updated': updated,
|
||||||
'hash': githash,
|
'hash': githash,
|
||||||
|
'tag': tag,
|
||||||
|
'tags': tags,
|
||||||
'url': url
|
'url': url
|
||||||
}
|
}
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
@ -669,6 +674,8 @@ def bench_refresh():
|
||||||
AVAILABLE_FIELDS = {
|
AVAILABLE_FIELDS = {
|
||||||
'version.app': ('version', 'app'),
|
'version.app': ('version', 'app'),
|
||||||
'version.hash': ('version', 'hash'),
|
'version.hash': ('version', 'hash'),
|
||||||
|
'version.tag': ('version', 'tag'),
|
||||||
|
'version.tags': ('version', 'tags'),
|
||||||
'version.updated': ('version', 'updated'),
|
'version.updated': ('version', 'updated'),
|
||||||
'version.url': ('version', 'url'),
|
'version.url': ('version', 'url'),
|
||||||
'platform.arch': ('platform', 'arch'),
|
'platform.arch': ('platform', 'arch'),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue