2012-05-28 26 views
6

Trong version.py có một phương pháp get_git_version() khi tôi thực hiện ./manage.py runserver lỗi này được huy động từ version.py tập tinget_git_version không thể tìm thấy số phiên bản

nâng ValueError ("Không thể tìm thấy số phiên bản!")

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 
+0

def read_release_version(): thử: f = open ("RELEASE-VERSION", "r") thử: phiên bản = f.readlines() [0] trở version.strip() cuối cùng: f.close() ngoại trừ: return None –

+1

Kiểm tra đường dẫn cho tệp 'RELEASE-VERSION'. Ngoài ra, hãy kiểm tra bằng cách đính kèm phần mở rộng của tệp trong khi mở tệp, chẳng hạn như 'RELEASE-VERSION.txt'. –

Trả lời

2

Tập lệnh này dự kiến ​​số phiên bản từ thẻ được chú thích git (call_git_describe()) hoặc bằng cách tìm số phiên bản trong tệp có tên RELEASE-VERSION. Nó thất bại vì không tìm thấy hai thứ này, vì vậy hãy sửa một trong số chúng.

Run này trong dự án của bạn để tạo chú thích tag cho hiện cam kết:

git tag 1.0 -m "this is version 1.0" 

Tôi có xu hướng thích gắn thẻ để quản lý phiên bản, nhưng phiên bản trong một file văn bản cũng tốt, YMMV.

Các vấn đề liên quan