Ejemplo n.º 1
0
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))
Ejemplo n.º 2
0
def _cmd_build_template(args, promote=False):
    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(args.templates, repo_info, next_custom, promote)
Ejemplo n.º 3
0
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.")
Ejemplo n.º 4
0
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))
Ejemplo n.º 5
0
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))
Ejemplo n.º 6
0
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))
Ejemplo n.º 7
0
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)
Ejemplo n.º 8
0
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)
Ejemplo n.º 9
0
def cmd_clean(args):
    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()
        print "Cleaned up custom string version \"" + next_custom + \
              "\" for tag \"" + tag + "\""
    else:
        print "No custom string version found for tag \"" + tag + "\""
Ejemplo n.º 10
0
def cmd_next(args):
    next_store = KVStore(NEXT_STORE_FILE)
    repo_info = get_repo_info()

    last_tag = repo_info['last-tag']

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

    custom = "%d.%d.%d" % (int(user[0]), int(user[1]), int(user[2]))
    next_store.set(last_tag, custom).save()
    print "Set NEXT version string to " + color_next(custom) + \
          " for the current tag " + color_tag(last_tag)
Ejemplo n.º 11
0
def cmd_info(args):
    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 = color_next(next_custom)
    else:
        nvn = "none defined, using " + color_next("-" + cfg['next_suffix']) + \
              " suffix"

    print "Most recent tag: " + color_tag(last_tag)
    print "NEXT defined as: " + nvn
    print "Current build ID: " + color_tag(repo_info['full-build-id'])
    print "Current version: " + \
          color_version("v" + build_version_string(repo_info, next_custom))
Ejemplo n.º 12
0
def cmd_list_next(args):
    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):
            print "    %s => %s" % (color_tag(k), color_next(v)) +\
                  (' (*)' if k == last_tag else '')

        print "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:
        print "No NEXT custom strings set."
Ejemplo n.º 13
0
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 + "\"")
Ejemplo n.º 14
0
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 + "\"")
Ejemplo n.º 15
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 '')
    )
Ejemplo n.º 16
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 '')
    )
Ejemplo n.º 17
0
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.")