Closed
Description
On my Linux distro (currently Ubuntu 22.04 via WSL) if I set the default branch to main
by running:
git config --global init.defaultBranch main
... then 2 (currently) tests will fail on pre-commit hooks.
========================================================================================================================= FAILURES =========================================================================================================================
______________________________________________________________________________________________________________ test_worktree_merge_conflicts _______________________________________________________________________________________________________________
f1_is_a_conflict_file = local('/tmp/pytest-of-root/pytest-0/test_worktree_merge_conflicts0/repo2'), tmpdir = local('/tmp/pytest-of-root/pytest-0/test_worktree_merge_conflicts0'), capsys = <_pytest.capture.CaptureFixture object at 0x7f8544e2c8b0>
def test_worktree_merge_conflicts(f1_is_a_conflict_file, tmpdir, capsys):
worktree = tmpdir.join('worktree')
cmd_output('git', 'worktree', 'add', str(worktree))
with worktree.as_cwd():
cmd_output(
'git', 'pull', '--no-rebase', 'origin', 'master', retcode=None,
)
msg = f1_is_a_conflict_file.join('.git/worktrees/worktree/MERGE_MSG')
> assert msg.exists()
E AssertionError: assert False
E + where False = <bound method LocalPath.exists of local('/tmp/pytest-of-root/pytest-0/test_worktree_merge_conflicts0/repo2/.git/worktrees/worktree/MERGE_MSG')>()
E + where <bound method LocalPath.exists of local('/tmp/pytest-of-root/pytest-0/test_worktree_merge_conflicts0/repo2/.git/worktrees/worktree/MERGE_MSG')> = local('/tmp/pytest-of-root/pytest-0/test_worktree_merge_conflicts0/repo2/.git/worktrees/worktree/MERGE_MSG').exists
/pch/pre-commit-hooks/tests/check_merge_conflict_test.py:156: AssertionError
------------------------------------------------------------------------------------------------------------------ Captured stdout setup -------------------------------------------------------------------------------------------------------------------
[main (root-commit) a28205d] commit1
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 f1
[main 626081f] master commit2
1 file changed, 1 insertion(+)
[main cc727a0] clone commit2
1 file changed, 1 insertion(+)
____________________________________________________________________________________________________________________ test_master_branch ____________________________________________________________________________________________________________________
temp_git_dir = local('/tmp/pytest-of-root/pytest-0/test_master_branch0/gits')
def test_master_branch(temp_git_dir):
with temp_git_dir.as_cwd():
> assert is_on_branch({'master'}) is True
E AssertionError: assert False is True
E + where False = is_on_branch({'master'})
tests/no_commit_to_branch_test.py:31: AssertionError
================================================================================================================= short test summary info ==================================================================================================================
FAILED tests/check_merge_conflict_test.py::test_worktree_merge_conflicts - AssertionError: assert False
FAILED tests/no_commit_to_branch_test.py::test_master_branch - AssertionError: assert False is True
This is concerning because on a fresh install of 22.04 with Git simply running git init /tmp/dummy
you'll get this message telling you to set your default branch.
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: git branch -m <name>
Initialized empty Git repository in /tmp/dummy/.git/
Metadata
Metadata
Assignees
Labels
No labels