Make more readable --from-ref / --to-ref aliases for --source / --origin

This commit is contained in:
Anthony Sottile 2020-02-23 11:07:57 -08:00
parent 566f1afcd4
commit d35b00352f
8 changed files with 72 additions and 61 deletions

View file

@ -109,8 +109,8 @@ def test_run_ns_post_checkout():
assert ns is not None
assert ns.hook_stage == 'post-checkout'
assert ns.color is True
assert ns.source == 'a'
assert ns.origin == 'b'
assert ns.from_ref == 'a'
assert ns.to_ref == 'b'
assert ns.checkout_type == 'c'
@ -140,8 +140,8 @@ def test_run_ns_pre_push_updating_branch(push_example):
assert ns.color is False
assert ns.remote_name == 'origin'
assert ns.remote_url == src
assert ns.source == src_head
assert ns.origin == clone_head
assert ns.from_ref == src_head
assert ns.to_ref == clone_head
assert ns.all_files is False
@ -154,8 +154,8 @@ def test_run_ns_pre_push_new_branch(push_example):
ns = hook_impl._run_ns('pre-push', False, args, stdin)
assert ns is not None
assert ns.source == src_head
assert ns.origin == clone_head
assert ns.from_ref == src_head
assert ns.to_ref == clone_head
def test_run_ns_pre_push_new_branch_existing_rev(push_example):

View file

@ -446,29 +446,29 @@ def test_hook_verbose_enabled(cap_out, store, repo_with_passing_hook):
@pytest.mark.parametrize(
('origin', 'source'), (('master', ''), ('', 'master')),
('from_ref', 'to_ref'), (('master', ''), ('', 'master')),
)
def test_origin_source_error_msg_error(
cap_out, store, repo_with_passing_hook, origin, source,
def test_from_ref_to_ref_error_msg_error(
cap_out, store, repo_with_passing_hook, from_ref, to_ref,
):
args = run_opts(origin=origin, source=source)
args = run_opts(from_ref=from_ref, to_ref=to_ref)
ret, printed = _do_run(cap_out, store, repo_with_passing_hook, args)
assert ret == 1
assert b'Specify both --origin and --source.' in printed
assert b'Specify both --from-ref and --to-ref.' in printed
def test_all_push_options_ok(cap_out, store, repo_with_passing_hook):
args = run_opts(
origin='master', source='master',
from_ref='master', to_ref='master',
remote_name='origin', remote_url='https://example.com/repo',
)
ret, printed = _do_run(cap_out, store, repo_with_passing_hook, args)
assert ret == 0
assert b'Specify both --origin and --source.' not in printed
assert b'Specify both --from-ref and --to-ref.' not in printed
def test_checkout_type(cap_out, store, repo_with_passing_hook):
args = run_opts(origin='', source='', checkout_type='1')
args = run_opts(from_ref='', to_ref='', checkout_type='1')
environ: EnvironT = {}
ret, printed = _do_run(
cap_out, store, repo_with_passing_hook, args, environ,