@@ -484,6 +484,49 @@ def test_branch_unset_upstream(git_repo: GitSync) -> None:
484484 assert result == "" or "upstream" not in result .lower ()
485485
486486
487+ def test_branch_track (git_repo : GitSync ) -> None :
488+ """Test GitBranchCmd.track()."""
489+ branch_name = "tracking-test-branch"
490+
491+ branch = git .GitBranchCmd (path = git_repo .path , branch_name = branch_name )
492+ result = branch .track ("origin/master" )
493+
494+ # Should create branch tracking origin/master
495+ assert "set up to track" in result .lower ()
496+
497+ # Verify branch was created
498+ branches = git_repo .cmd .branches .ls ()
499+ branch_names = [b .branch_name for b in branches ]
500+ assert branch_name in branch_names
501+
502+
503+ def test_branch_ls_filters (git_repo : GitSync ) -> None :
504+ """Test GitBranchManager.ls() with filter parameters."""
505+ # Test basic ls
506+ branches = git_repo .cmd .branches .ls ()
507+ assert len (branches ) >= 1
508+ assert any (b .branch_name == "master" for b in branches )
509+
510+ # Test with --all (includes remote-tracking branches)
511+ all_branches = git_repo .cmd .branches .ls (_all = True )
512+ assert len (all_branches ) >= len (branches )
513+
514+ # Test with --merged (branches merged into HEAD)
515+ merged = git_repo .cmd .branches .ls (merged = "HEAD" )
516+ assert isinstance (merged , list )
517+ # master should be merged into HEAD
518+ assert any (b .branch_name == "master" for b in merged )
519+
520+ # Test with --contains (branches containing HEAD commit)
521+ contains = git_repo .cmd .branches .ls (contains = "HEAD" )
522+ assert isinstance (contains , list )
523+ assert any (b .branch_name == "master" for b in contains )
524+
525+ # Test with --sort
526+ sorted_branches = git_repo .cmd .branches .ls (sort = "refname" )
527+ assert isinstance (sorted_branches , list )
528+
529+
487530# =============================================================================
488531# GitRemoteCmd Tests
489532# =============================================================================
0 commit comments