6

私が実行するとこのエラーがファイルから発生するversion.pyメソッドがありますget_git_version()./manage.py runserverversion.py

ValueError( "バージョン番号が見つかりません!")を発生させます

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
4

1 に答える 1

4

このスクリプトは、git注釈付きタグ(call_git_describe())から、または。という名前のファイルでバージョン番号を検索することにより、バージョン番号を予期していますRELEASE-VERSION。これら2つが見つからないために失敗するので、そのうちの1つを修正します。

プロジェクトでこれを実行して、現在のコミットの注釈付きタグを作成します。

git tag 1.0 -m "this is version 1.0"

私はバージョン管理にタグ付けを好む傾向がありますが、テキストファイルのバージョンも良いです、YMMV。

于 2012-05-29T10:27:15.040 に答える