Exemple #1
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)
Exemple #2
0
def run(args):
    allcomps = MepoState.read_state()
    comps2unstg = _get_comps_to_unstage(args.comp_name, allcomps)
    for comp in comps2unstg:
        git = GitRepository(comp.remote, comp.local)
        staged_files = git.get_staged_files()
        for myfile in staged_files:
            git.unstage_file(myfile)
            print('- {}: {}'.format(comp.name, myfile))