import subprocessimport sysdef get_local_latest_tag():result = subprocess.run(['git', 'describe', '--abbrev=0', '--tags'], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True).stdoutif result:return result.strip()else:return ''def get_head_tag():result = subprocess.run(['git', 'describe', '--exact-match', 'HEAD'], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True).stdoutif result:return result.strip()else:return ''def get_head_commit_id():result = subprocess.run(['git', 'rev-parse', '--verify', 'HEAD'], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True).stdoutif result:return result.strip()else:return ''def print_version():commit_id = get_head_commit_id()if not commit_id:print("Error: Needed a single revision.")sys.exit(1)latest_tag = get_local_latest_tag()if not latest_tag:print(f"({commit_id[:7]})")sys.exit(0)head_tag = get_head_tag()if head_tag == latest_tag:print(f"{latest_tag} ({commit_id[:7]})")else:print(f"+ {latest_tag} ({commit_id[:7]})")
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。