コード例 #1
0
ファイル: commands.py プロジェクト: movermeyer/gitver
def cmd_list_next(cfg, args):
    """
    Generates a list of all user-defined next stable versions and prints them
    to the stdout.
    """
    next_store = KVStore(NEXT_STORE_FILE)
    repo_info = get_repo_info()
    last_tag = repo_info['last-tag']
    has_next_custom = next_store.has(last_tag)
    if not next_store.empty():

        def print_item(k, v):
            term.out("    %s => %s" % (term.tag(k), term.next(v)) +
                     (' (*)' if k == last_tag else ''))

        term.out("Currently set NEXT custom strings (*=most recent and "
                 "reachable tag):")
        for tag, vstring in sorted(next_store.items()):
            print_item(tag, vstring)

        if not has_next_custom:
            print_item(last_tag, '<undefined>')

    else:
        term.out("No NEXT custom strings set.")
コード例 #2
0
ファイル: commands.py プロジェクト: movermeyer/gitver
def cmd_next(cfg, args):
    """
    Sets and defines the next stable version string for the most recent and
    reachable tag.

    The string should be supplied in the format "maj.min.patch[.revision]",
    where angular brackets denotes an optional value.

    All values are expected to be decimal numbers without leading zeros.
    """
    next_store = KVStore(NEXT_STORE_FILE)
    repo_info = get_repo_info()

    last_tag = repo_info['last-tag']

    vn = args.next_version_numbers
    user = parse_user_next_stable(vn)
    if not user:
        term.err("Please specify valid version numbers.\nThe expected "
                 "format is <MAJ>.<MIN>.<PATCH>[.<REVISION>], e.g. v0.0.1, "
                 "0.0.1 or 0.0.2.1")
        sys.exit(1)

    custom = "%d.%d.%d" % (int(user['maj']), int(
        user['min']), int(user['patch']))

    if user['revision'] is not None:
        custom += ".%d" % (int(user['revision']))

    next_store.set(last_tag, custom).save()
    term.out("Set NEXT version string to " + term.next(custom) +
             " for the current tag " + term.tag(last_tag))
コード例 #3
0
ファイル: commands.py プロジェクト: movermeyer/gitver
def cmd_current(cfg, args):
    """
    Generates the current version string, depending on the state of the
    repository and prints it to the stdout.
    """
    next_store = KVStore(NEXT_STORE_FILE)
    repo_info = get_repo_info()
    last_tag = repo_info['last-tag']
    has_next_custom = next_store.has(last_tag)
    next_custom = next_store.get(last_tag) if has_next_custom else None
    term.out(build_version_string(cfg, repo_info, False, next_custom))
コード例 #4
0
ファイル: commands.py プロジェクト: movermeyer/gitver
def __cmd_build_template(cfg, args, preview=False):
    """
    Internal-only function used for avoiding code duplication between
    template-operating functions.

    See cmd_build_template and cmd_preview_template for the full docs.
    """
    next_store = KVStore(NEXT_STORE_FILE)
    repo_info = get_repo_info()
    last_tag = repo_info['last-tag']
    has_next_custom = next_store.has(last_tag)
    next_custom = next_store.get(last_tag) if has_next_custom else None
    parse_templates(cfg, args.templates, repo_info, next_custom, preview)
コード例 #5
0
ファイル: commands.py プロジェクト: movermeyer/gitver
def cmd_clean(cfg, args):
    """
    Removes the user-defined next stable version for the most recent and
    reachable tag or for the tag specified by the @param args parameter.
    """
    next_store = KVStore(NEXT_STORE_FILE)
    if len(args.tag) > 0:
        tag = args.tag
    else:
        repo_info = get_repo_info()
        tag = repo_info['last-tag']

    has_custom = next_store.has(tag)
    next_custom = next_store.get(tag) if has_custom else None

    if has_custom:
        next_store.rm(tag).save()
        term.out("Cleaned up custom string version \"" + next_custom +
                 "\" for tag \"" + tag + "\"")
    else:
        term.out("No custom string version found for tag \"" + tag + "\"")
コード例 #6
0
def cmd_info(cfg, args):
    """
    Generates version string and repository information and prints it to the
    stdout.
    """
    next_store = KVStore(NEXT_STORE_FILE)
    repo_info = get_repo_info()
    last_tag = repo_info['last-tag']

    has_next_custom = next_store.has(last_tag)
    next_custom = next_store.get(last_tag) if has_next_custom else None

    if has_next_custom:
        nvn = term.next(next_custom)
    else:
        nvn = "none, defaulting to " + \
              term.next("-" + cfg['default_meta_pr_in_next_no_next']) + \
              " suffix"

    term.out("Most recent tag: " + term.tag(last_tag))

    if repo_info['pr'] is None and repo_info['count'] > 0:
        term.out("Using NEXT defined as: " + nvn)
        term.out("(Pre-release metadata: none)")
    elif repo_info['pr'] is not None:
        term.out("(NEXT defined as: " + nvn + ")")
        term.out("Using pre-release metadata: " +
                 term.tag(str(repo_info['pr'])))

    term.out("Current build ID: " + term.tag(repo_info['full-build-id']))

    promoted = build_version_string(cfg, repo_info, True, next_custom)
    term.out(
        "Current version: " + "v" +
        term.ver(build_version_string(
            cfg, repo_info, False, next_custom)) +
        (" => v" + term.prom(promoted) if len(promoted) > 0 else '')
    )