Exemplo n.º 1
0
def check_component_status(comp):
    git = GitRepository(comp.remote, comp.local)

    # version_to_string can strip off 'origin/' for display purposes
    # so we save the "internal" name for comparison
    internal_state_branch_name = git.get_version()[0]

    # This can return non "origin/" names for detached head branches
    curr_ver = version_to_string(git.get_version())
    orig_ver = version_to_string(comp.version)

    # This command is to try and work with git tag oddities
    curr_ver = sanitize_version_string(orig_ver,curr_ver,git)

    return (curr_ver, internal_state_branch_name, git.check_status())
Exemplo n.º 2
0
def run(args):
    allcomps = MepoState.read_state()
    max_namelen = len(max([x.name for x in allcomps], key=len))
    max_origlen = len(
        max([version_to_string(x.version) for x in allcomps], key=len))
    print_header(max_namelen, max_origlen)
    for comp in allcomps:
        git = GitRepository(comp.remote, comp.local)
        curr_ver = version_to_string(git.get_version())
        orig_ver = version_to_string(comp.version)

        # This command is to try and work with git tag oddities
        curr_ver = sanitize_version_string(orig_ver, curr_ver, git)

        print_cmp(comp.name, orig_ver, curr_ver, max_namelen, max_origlen)
Exemplo n.º 3
0
def run(args):
    allcomps = MepoState.read_state()
    verify.valid_components(args.comp_name, allcomps)
    comps2pull = [x for x in allcomps if x.name in args.comp_name]
    for comp in comps2pull:
        git = GitRepository(comp.remote, comp.local)
        name, tYpe, is_detached = MepoVersion(*git.get_version())
        if is_detached:
            raise Exception('{} has detached head! Cannot pull.'.format(
                comp.name))
        else:
            print("Pulling branch %s in %s " %
                  (colors.YELLOW + name + colors.RESET,
                   colors.RESET + comp.name + colors.RESET))
            output = git.pull()
            if not args.quiet: print(output)
Exemplo n.º 4
0
def _update_comp(comp):
    git = GitRepository(comp.remote, comp.local)
    orig_ver = comp.version
    curr_ver = MepoVersion(*git.get_version())

    orig_ver_is_tag_or_hash = (orig_ver.type == 't' or orig_ver.type == 'h')
    curr_ver_is_tag_or_hash = (curr_ver.type == 't' or curr_ver.type == 'h')

    if orig_ver_is_tag_or_hash and curr_ver_is_tag_or_hash:
        # This command is to try and work with git tag oddities
        curr_ver_to_use = sanitize_version_string(orig_ver.name, curr_ver.name,
                                                  git)
        if curr_ver_to_use == orig_ver.name:
            comp.version = orig_ver
        else:
            _verify_local_and_remote_commit_ids_match(git, curr_ver_to_use,
                                                      comp.name, curr_ver.type)
            comp.version = curr_ver
    else:
        if _version_has_changed(curr_ver, orig_ver, comp.name):
            _verify_local_and_remote_commit_ids_match(git, curr_ver.name,
                                                      comp.name, curr_ver.type)
            comp.version = curr_ver
Exemplo n.º 5
0
def check_component_status(comp):
    git = GitRepository(comp.remote, comp.local)
    curr_ver = version_to_string(git.get_version())
    return (curr_ver, git.check_status())