Beispiel #1
0
def get_repo_info():
    # retrieve basic repository information
    desc = describe()
    if not desc:
        print err("Error, this repository is required to define tags in the "
                  "format vX.Y.Z")
        sys.exit(1)

    # extract version string, assumes HEAD to be at that commit
    vmaj = int(desc[0])
    vmin = int(desc[1])
    vpatch = int(desc[2])
    vcount = int(desc[3])
    vhash = desc[4]
    hashlen = len(vhash)
    full_build_id = get_build_id()
    if not full_build_id or hashlen == 0:
        print err("Couldn't retrieve build id information")
        sys.exit(1)

    # sanity check
    if not full_build_id.startswith(vhash):
        print err("Hash problem detected: git-describe reports " + vhash +
                  ", but HEAD id is " + full_build_id)
        sys.exit(1)

    tag = last_tag()
    if not tag:
        print err("Couldn't retrieve the latest tag")
        sys.exit(1)

    return {'maj': vmaj, 'min': vmin, 'patch': vpatch, 'count': vcount,
            'build-id': full_build_id[:hashlen], 'full-build-id': full_build_id,
            'last-tag': tag}
Beispiel #2
0
def check_project_root():
    if len(PRJ_ROOT) == 0:
        print err("Couldn't determine your project's root directory, is this "
                  "a valid git repository?")
        sys.exit(1)