remove master references from tests

This commit is contained in:
Anthony Sottile 2025-04-19 11:46:43 -04:00
parent 6db05e22aa
commit 0a0af6796b
3 changed files with 18 additions and 19 deletions

View file

@ -27,10 +27,10 @@ def f1_is_a_conflict_file(tmpdir):
cmd_output('git', 'clone', str(repo1), str(repo2))
# Commit in master
# Commit in mainline
with repo1.as_cwd():
repo1_f1.write('parent\n')
git_commit('-am', 'master commit2')
git_commit('-am', 'mainline commit2')
# Commit in clone and pull
with repo2.as_cwd():
@ -82,10 +82,10 @@ def repository_pending_merge(tmpdir):
cmd_output('git', 'clone', str(repo1), str(repo2))
# Commit in master
# Commit in mainline
with repo1.as_cwd():
repo1_f1.write('parent\n')
git_commit('-am', 'master commit2')
git_commit('-am', 'mainline commit2')
# Commit in clone and pull without committing
with repo2.as_cwd():
@ -112,7 +112,7 @@ def test_merge_conflicts_git(capsys):
@pytest.mark.parametrize(
'contents', (b'<<<<<<< HEAD\n', b'=======\n', b'>>>>>>> master\n'),
'contents', (b'<<<<<<< HEAD\n', b'=======\n', b'>>>>>>> main\n'),
)
def test_merge_conflicts_failing(contents, repository_pending_merge):
repository_pending_merge.join('f2').write_binary(contents)
@ -150,7 +150,7 @@ def test_worktree_merge_conflicts(f1_is_a_conflict_file, tmpdir, capsys):
cmd_output('git', 'worktree', 'add', str(worktree))
with worktree.as_cwd():
cmd_output(
'git', 'pull', '--no-rebase', 'origin', 'master', retcode=None,
'git', 'pull', '--no-rebase', 'origin', 'HEAD', retcode=None,
)
msg = f1_is_a_conflict_file.join('.git/worktrees/worktree/MERGE_MSG')
assert msg.exists()

View file

@ -16,9 +16,9 @@ def test_passing(tmpdir):
# tags are ok
b'https://github.com/asottile/test/blob/1.0.0/foo%20bar#L1\n'
# links to files but not line numbers are ok
b'https://github.com/asottile/test/blob/master/foo%20bar\n'
b'https://github.com/asottile/test/blob/main/foo%20bar\n'
# regression test for overly-greedy regex
b'https://github.com/ yes / no ? /blob/master/foo#L1\n',
b'https://github.com/ yes / no ? /blob/main/foo#L1\n',
)
assert not main((str(f),))
@ -26,17 +26,15 @@ def test_passing(tmpdir):
def test_failing(tmpdir, capsys):
with tmpdir.as_cwd():
tmpdir.join('f.txt').write_binary(
b'https://github.com/asottile/test/blob/master/foo#L1\n'
b'https://example.com/asottile/test/blob/master/foo#L1\n'
b'https://github.com/asottile/test/blob/main/foo#L1\n'
b'https://example.com/asottile/test/blob/main/foo#L1\n',
)
assert main(('f.txt', '--additional-github-domain', 'example.com'))
out, _ = capsys.readouterr()
assert out == (
'f.txt:1:https://github.com/asottile/test/blob/master/foo#L1\n'
'f.txt:2:https://example.com/asottile/test/blob/master/foo#L1\n'
'f.txt:3:https://example.com/asottile/test/blob/main/foo#L1\n'
'f.txt:1:https://github.com/asottile/test/blob/main/foo#L1\n'
'f.txt:2:https://example.com/asottile/test/blob/main/foo#L1\n'
'\n'
'Non-permanent github link detected.\n'
'On any page on github press [y] to load a permalink.\n'

View file

@ -11,13 +11,13 @@ from testing.util import git_commit
def test_other_branch(temp_git_dir):
with temp_git_dir.as_cwd():
cmd_output('git', 'checkout', '-b', 'anotherbranch')
assert is_on_branch({'master'}) is False
assert is_on_branch({'placeholder'}) is False
def test_multi_branch(temp_git_dir):
with temp_git_dir.as_cwd():
cmd_output('git', 'checkout', '-b', 'another/branch')
assert is_on_branch({'master'}) is False
assert is_on_branch({'placeholder'}) is False
def test_multi_branch_fail(temp_git_dir):
@ -26,9 +26,10 @@ def test_multi_branch_fail(temp_git_dir):
assert is_on_branch({'another/branch'}) is True
def test_master_branch(temp_git_dir):
def test_exact_branch(temp_git_dir):
with temp_git_dir.as_cwd():
assert is_on_branch({'master'}) is True
cmd_output('git', 'checkout', '-b', 'branchname')
assert is_on_branch({'branchname'}) is True
def test_main_branch_call(temp_git_dir):
@ -50,11 +51,11 @@ def test_branch_pattern_fail(temp_git_dir):
assert is_on_branch(set(), {'another/.*'}) is True
@pytest.mark.parametrize('branch_name', ('master', 'another/branch'))
@pytest.mark.parametrize('branch_name', ('somebranch', 'another/branch'))
def test_branch_pattern_multiple_branches_fail(temp_git_dir, branch_name):
with temp_git_dir.as_cwd():
cmd_output('git', 'checkout', '-b', branch_name)
assert main(('--branch', 'master', '--pattern', 'another/.*'))
assert main(('--branch', 'somebranch', '--pattern', 'another/.*'))
def test_main_default_call(temp_git_dir):