gpt4 book ai didi

django - get_git_version 找不到版本号

转载 作者:太空狗 更新时间:2023-10-29 13:14:49 25 4
gpt4 key购买 nike

version.py 中有一个方法 get_git_version() 当我执行 ./manage.py runserver 这个错误是从 version.py 文件

raise ValueError("Cannot find the version number!")

def get_git_version(abbrev=4):
# Read in the version that's currently in RELEASE-VERSION.

release_version = read_release_version()

# First try to get the current version using "git describe".

version = call_git_describe(abbrev)

# If that doesn't work, fall back on the value that's in
# RELEASE-VERSION.

if version is None:
version = release_version

# If we still don't have anything, that's an error.

if version is None:
raise ValueError("Cannot find the version number!")

# If the current version is different from what's in the
# RELEASE-VERSION file, update the file to be current.

if version != release_version:
write_release_version(version)

# Finally, return the current version.

return version


def read_release_version():
try:
f = open("RELEASE-VERSION", "r")

try:
version = f.readlines()[0]
return version.strip()

finally:
f.close()
except:
return None

最佳答案

此脚本需要来自 git 注释标记 (call_git_describe()) 的版本号,或者通过在名为 RELEASE-VERSION 的文件中查找版本号。失败是因为这两个东西都没有找到,所以修复其中一个。

在你的项目中运行这个为当前提交创建带注释的标签:

git tag 1.0 -m "this is version 1.0"

我倾向于更喜欢标记版本管理,但文本文件中的版本也不错,YMMV。

关于django - get_git_version 找不到版本号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10783087/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com