Skip to content

Commit 152d77f

Browse files
committed
cmd/git(feat[GitBranchManager.ls]): add verbose parameter
why: Complete GitBranchManager.ls() filter options to match GitTagManager.ls() what: - Add verbose: bool parameter to ls() method - Add helper function to extract branch name from verbose output - Verbose output format is "name sha1 message" - parse correctly
1 parent 8cf1b24 commit 152d77f

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

src/libvcs/cmd/git.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5726,6 +5726,7 @@ def ls(
57265726
no_merged: str | None = None,
57275727
contains: str | None = None,
57285728
sort: str | None = None,
5729+
verbose: bool = False,
57295730
) -> QueryList[GitBranchCmd]:
57305731
"""List branches.
57315732
@@ -5743,6 +5744,8 @@ def ls(
57435744
Only list branches containing specified commit.
57445745
sort :
57455746
Sort key (e.g., '-committerdate', 'refname').
5747+
verbose :
5748+
Show sha1 and commit subject line for each head. Maps to --verbose.
57465749
57475750
Examples
57485751
--------
@@ -5763,11 +5766,22 @@ def ls(
57635766
local_flags.extend(["--contains", contains])
57645767
if sort is not None:
57655768
local_flags.extend(["--sort", sort])
5769+
if verbose:
5770+
local_flags.append("--verbose")
5771+
5772+
def extract_branch_name(line: str) -> str:
5773+
"""Extract branch name from output line (handles verbose output)."""
5774+
# Strip leading "* " or " " marker
5775+
name = line.lstrip("* ")
5776+
# With --verbose, format is: "name sha1 message" - take first token
5777+
if verbose:
5778+
name = name.split()[0] if name.split() else name
5779+
return name
57665780

57675781
return QueryList(
57685782
[
5769-
GitBranchCmd(path=self.path, branch_name=branch_name.lstrip("* "))
5770-
for branch_name in self._ls(local_flags=local_flags or None)
5783+
GitBranchCmd(path=self.path, branch_name=extract_branch_name(line))
5784+
for line in self._ls(local_flags=local_flags or None)
57715785
],
57725786
)
57735787

0 commit comments

Comments
 (0)