Пример #1
0
def run(args):
    allcomps = MepoState.read_state()
    verify.valid_components(args.comp_name, allcomps)
    comps2appst = [x for x in allcomps if x.name in args.comp_name]
    for comp in comps2appst:
        git = GitRepository(comp.remote, comp.local)
        git.apply_stash()
Пример #2
0
def run(args):
    allcomps = MepoState.read_state()
    verify.valid_components(args.comp_name, allcomps)
    comps2commit = [x for x in allcomps if x.name in args.comp_name]

    tf_file = None

    # Pop up an editor if a message is not provided
    if not args.message:
        EDITOR = git_var('GIT_EDITOR')
        initial_message = b"" # set up the file

        # Use delete=False to keep the file around as we send the file name to git commit -F
        tf = tempfile.NamedTemporaryFile(delete=False)
        tf_file = tf.name
        tf.write(initial_message)
        tf.flush()
        subprocess.call([EDITOR, tf.name])

    for comp in comps2commit:
        git = GitRepository(comp.remote, comp.local)
        if args.all:
            stage_files(git, comp, commit=True)

        staged_files = git.get_staged_files()
        if staged_files:
            git.commit_files(args.message,tf_file)

        for myfile in staged_files:
            print('+ {}: {}'.format(comp.name, myfile))

    # Now close and by-hand delete the temp file
    if not args.message:
        tf.close()
        os.unlink(tf.name)
Пример #3
0
def run(args):
    allcomps = MepoState.read_state()
    verify.valid_components(args.comp_name, allcomps)
    comps2stg = [x for x in allcomps if x.name in args.comp_name]
    for comp in comps2stg:
        git = GitRepository(comp.remote, comp.local)
        stage_files(git, comp, args.untracked)
Пример #4
0
def run(args):
    allcomps = MepoState.read_state()
    verify.valid_components(args.comp_name, allcomps)
    comps2crtbr = [x for x in allcomps if x.name in args.comp_name]
    for comp in comps2crtbr:
        git = GitRepository(comp.remote, comp.local)
        git.create_branch(args.branch_name)
        print('+ {}: {}'.format(comp.name, args.branch_name))
Пример #5
0
def run(args):
    allcomps = MepoState.read_state()
    verify.valid_components(args.comp_name, allcomps)
    comps2tagpush = _get_comps_to_list(args.comp_name, allcomps)
    for comp in comps2tagpush:
        git = GitRepository(comp.remote, comp.local)
        git.push_tag(args.tag_name, args.force)
        print(f'Pushed tag {args.tag_name} to {comp.name}')
Пример #6
0
def run(args):
    allcomps = MepoState.read_state()
    verify.valid_components(args.comp_name, allcomps)
    comps2deltg = _get_comps_to_list(args.comp_name, allcomps)
    for comp in comps2deltg:
        git = GitRepository(comp.remote, comp.local)
        git.delete_tag(args.tag_name)
        print('- {}: {}'.format(comp.name, args.tag_name))
Пример #7
0
def run(args):
    allcomps = MepoState.read_state()
    verify.valid_components(args.comp_name, allcomps)
    comps2showst = [x for x in allcomps if x.name in args.comp_name]
    for comp in comps2showst:
        git = GitRepository(comp.remote, comp.local)
        result = git.show_stash(args.patch)
        print(result)
Пример #8
0
def run(args):
    allcomps = MepoState.read_state()
    verify.valid_components(args.comp_name, allcomps)
    comps2push = [x for x in allcomps if x.name in args.comp_name]
    for comp in comps2push:
        git = GitRepository(comp.remote, comp.local)
        output = git.push()
        print('----------\nPushed: {}\n----------'.format(comp.name))
        print(output)
Пример #9
0
def run(args):
    allcomps = MepoState.read_state()
    verify.valid_components(args.comp_name, allcomps)
    comps2dev = [x for x in allcomps if x.name in args.comp_name]
    for comp in comps2dev:
        git = GitRepository(comp.remote, comp.local)
        if comp.develop is None:
            raise Exception("'develop' branch not specified for {}".format(
                comp.name))
        if not args.quiet:
            print("Checking out development branch %s in %s" %
                  (colors.YELLOW + comp.develop + colors.RESET,
                   colors.RESET + comp.name + colors.RESET))
        git.checkout(comp.develop)
        output = git.pull()
Пример #10
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)
Пример #11
0
def run(args):
    root_dir = MepoState.get_root_dir()
    allcomps = MepoState.read_state()
    if args.comp_name:  # single comp name is specified, print relpath
        if args.comp_name == "_root":
            # _root is a "hidden" allowed argument for whereis to return
            # the root dir of the project. Mainly used by mepo-cd
            print(root_dir)
        else:
            verify.valid_components([args.comp_name], allcomps)
            for comp in allcomps:
                if comp.name == args.comp_name:
                    full_local_path = os.path.join(root_dir, comp.local)
                    print(_get_relative_path(full_local_path))
    else:  # print relpaths of all comps
        max_namelen = len(max([x.name for x in allcomps], key=len))
        FMT = '{:<%s.%ss} | {:<s}' % (max_namelen, max_namelen)
        for comp in allcomps:
            full_local_path = os.path.join(root_dir, comp.local)
            print(FMT.format(comp.name, _get_relative_path(full_local_path)))
Пример #12
0
def _get_comps_to_checkout(specified_comps, allcomps):
    comps_to_list = allcomps
    if specified_comps:
        verify.valid_components(specified_comps, allcomps)
        comps_to_list = [x for x in allcomps if x.name in specified_comps]
    return comps_to_list
Пример #13
0
def _get_comps_to_unstage(specified_comps, allcomps):
    comps_to_unstage = allcomps
    if specified_comps:
        verify.valid_components(specified_comps, allcomps)
        comps_to_unstage = [x for x in allcomps if x.name in specified_comps]
    return comps_to_unstage