11# Copyright (C) 2020 Sebastian Pipping <[email protected] > 22# Licensed under GPL v3 or later
33import os
4+ import shlex
45import subprocess
56from tempfile import TemporaryDirectory
67from textwrap import dedent
@@ -27,6 +28,33 @@ def test_find_branches_drops_head(self):
2728
2829 self .assertEqual (actual_branches , expected_branches )
2930
31+ @parameterized .expand (
32+ [
33+ # NOTE: No point in testing values "never" or "auto"
34+ ("column.ui" , "always" ),
35+ # NOTE: No point in testing value "plain"
36+ ("column.branch" , "column" ),
37+ ("column.branch" , "row" ),
38+ ]
39+ )
40+ def test_find_branches_robust_towards_column_mode (self , git_config_key , git_config_value ):
41+ expected_branches = ["main_1" , "main_2" ]
42+ with TemporaryDirectory () as tempdir :
43+ run_script (
44+ dedent (
45+ f"""
46+ git -c init.defaultBranch=main_1 init
47+ git commit --allow-empty -m 'First commit'
48+ git config { shlex .quote (git_config_key )} { shlex .quote (git_config_value )}
49+ git branch main_2 main_1
50+ """
51+ ),
52+ tempdir ,
53+ )
54+ git = Git (Messenger (colorize = False ), pretend = True , verbose = False , work_dir = tempdir )
55+ actual_branches = git ._find_branches ()
56+ self .assertEqual (actual_branches , expected_branches )
57+
3058
3159class FindBranchNamesTest (TestCase ):
3260 def test (self ):
0 commit comments