Skip to content

Commit ea59519

Browse files
committed
cmd/git(fix[GitRemoteManager.add]): Validate mirror parameter correctly
why: The assert statement was checking `any(f for f in ["push", "fetch"])` which always returns True since non-empty strings are truthy. The actual mirror value was never validated. what: - Replace always-true assertion with proper validation - Raise ValueError if mirror is not 'push' or 'fetch' - Fix --mirror syntax to use = format per git-remote docs - Simplify bool check with elif
1 parent 7cf3f46 commit ea59519

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/libvcs/cmd/git.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4265,9 +4265,11 @@ def add(
42654265
local_flags.extend(["-m", master])
42664266
if mirror is not None:
42674267
if isinstance(mirror, str):
4268-
assert any(f for f in ["push", "fetch"])
4269-
local_flags.extend(["--mirror", mirror])
4270-
if isinstance(mirror, bool) and mirror:
4268+
if mirror not in ("push", "fetch"):
4269+
msg = "mirror must be 'push' or 'fetch'"
4270+
raise ValueError(msg)
4271+
local_flags.append(f"--mirror={mirror}")
4272+
elif mirror is True:
42714273
local_flags.append("--mirror")
42724274
return self.run(
42734275
"add",

0 commit comments

Comments
 (0)