Beispiel #1
0
def handle_file_based_commit(file_path, debug_mode, args):
    with open(str(file_path), 'r') as stream:
        try:
            config = safe_load(stream)
            debug('convention from file', config['convention'], debug_mode)
            convention = dump_convention(config)

            if convention == 'none':
                notify('You are not using a convention')
                if args.message is not '':
                    commit_msg = just_message(msg=args.message)
                else:
                    commit_msg = just_message()

            elif convention == 'custom':
                notify('You are using your custom convention')
                validate_commiter_file(config)
                tag, msg = get_text()
                commit_msg = custom_convention(tag, msg, config, debug_mode)

            else:
                notify('You are using the %s convention' % convention)
                commit_msg = handle_conventioned_commit(convention, args)

            commit_msg += gen_co_author(args.co_author)
            debug('commit message', commit_msg, debug_mode)
            system('git commit -m "%s"' % commit_msg)

        except YAMLError as err:
            print(err)
def convention_flag_handler(args, debug_mode):
    convention = str(args.convention)
    debug('convention flag', convention, debug_mode)

    if convention == 'message':
        if args.message is not '':
            commit_message = just_message(msg=args.message)
        else:
            commit_message = just_message()
        convention = 'none'

    else:
        commit_message = handle_conventioned_commit(convention, args)

    create_file(convention, args.no_file)
    commit_message += gen_co_author(args.co_author)
    debug('commit message', commit_message, debug_mode)
    system('git commit -m "%s"' % commit_message)
Beispiel #3
0
def test_no_convention_without_args():
    inputs = [
        "message",
    ]

    def mock_input(s):
        return inputs.pop(0)

    no_convention.input = mock_input
    message = no_convention.just_message()
    if not message == 'Message\n':
        raise AssertionError()
Beispiel #4
0
def test_no_convention_with_args():
    message = no_convention.just_message('Message')
    if not message == 'Message\n':
        raise AssertionError()