| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a495ccd commit 96a888f
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1044,13 +1044,21 @@ def _option_candidates(cls, args: Sequence[Any] = (), kwargs: Optional[Mapping[s | |||
| 1044 | 1044 | values = value if isinstance(value, (list, tuple)) else (value,) | |
| 1045 | 1045 | if any(value is True or (value is not False and value is not None) for value in values): | |
| 1046 | 1046 | key = str(key) | |
| 1047 | - options.append(f"-{key}" if len(key) == 1 else f"--{dashify(key)}") | ||
| 1048 | - if len(key) == 1 and split_single_char_options: | ||
| 1047 | + if len(key) != 1: | ||
| 1048 | + options.append(f"--{dashify(key)}") | ||
| 1049 | + elif split_single_char_options: | ||
| 1050 | + options.append(f"-{key}") | ||
| 1049 | 1051 | options.extend( | |
| 1050 | 1052 | str(value) | |
| 1051 | 1053 | for value in values | |
| 1052 | 1054 | if value is not True and value not in (False, None) and str(value).startswith("-") | |
| 1053 | 1055 | ) | |
| 1056 | + else: | ||
| 1057 | + options.extend( | ||
| 1058 | + f"-{key}" if value is True else f"-{key}{value}" | ||
| 1059 | + for value in values | ||
| 1060 | + if value is True or (value is not False and value is not None) | ||
| 1061 | + ) | ||
| 1054 | 1062 | return options | |
| 1055 | 1063 | ||
| 1056 | 1064 | AutoInterrupt: TypeAlias = _AutoInterrupt | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -230,7 +230,15 @@ def test_option_candidates_include_split_single_char_option_values(self): | |||
| 230 | 230 | ||
| 231 | 231 | unsplit_kwargs = {"n": "--upload-pack=helper", "split_single_char_options": False} | |
| 232 | 232 | self.assertEqual(self.git.transform_kwargs(**unsplit_kwargs), ["-n--upload-pack=helper"]) | |
| 233 | - self.assertEqual(Git._option_candidates(kwargs=unsplit_kwargs), ["-n"]) | ||
| 233 | + self.assertEqual(Git._option_candidates(kwargs=unsplit_kwargs), ["-n--upload-pack=helper"]) | ||
| 234 | + | ||
| 235 | + def test_option_candidates_include_joined_single_char_option_values(self): | ||
| 236 | + kwargs = {"n": "uhelper", "split_single_char_options": False} | ||
| 237 | + candidates = Git._option_candidates(kwargs=kwargs) | ||
| 238 | + | ||
| 239 | + self.assertEqual(candidates, ["-nuhelper"]) | ||
| 240 | + with self.assertRaises(UnsafeOptionError): | ||
| 241 | + Git.check_unsafe_options(options=candidates, unsafe_options=["-u"]) | ||
| 234 | 242 | ||
| 235 | 243 | _shell_cases = ( | |
| 236 | 244 | # value_in_call, value_from_class, expected_popen_arg | |
| Back | FazBrowse Home | New Git URL |
0 commit comments