Skip to content

Commit e96279f

Browse files
committed
cmd(git): Stub out branch
1 parent 0e22683 commit e96279f

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

src/libvcs/cmd/git.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2959,9 +2959,15 @@ def save(
29592959
GitBranchCommandLiteral = Literal[
29602960
"create", # checkout -b
29612961
"checkout", # checkout
2962+
"_list",
29622963
"move", # branch -m, or branch -M with force
29632964
"copy", # branch -c, or branch -C with force
29642965
"delete", # branch -d, or branch -D /ith force
2966+
"set_upstream",
2967+
"unset_upstream",
2968+
"track",
2969+
"no_track",
2970+
"edit_description",
29652971
]
29662972

29672973

@@ -3035,3 +3041,35 @@ def run(
30353041
check_returncode=check_returncode,
30363042
log_in_real_time=log_in_real_time,
30373043
)
3044+
3045+
def checkout(self, *, branch: str) -> str:
3046+
"""Git branch checkout.
3047+
3048+
Examples
3049+
--------
3050+
>>> GitBranchCmd(path=git_local_clone.path).checkout(branch='master')
3051+
"Your branch is up to date with 'origin/master'."
3052+
"""
3053+
return self.cmd.run(
3054+
[
3055+
"checkout",
3056+
*[branch],
3057+
],
3058+
)
3059+
3060+
def create(self, *, branch: str) -> str:
3061+
"""Create a git branch.
3062+
3063+
Examples
3064+
--------
3065+
>>> GitBranchCmd(path=git_local_clone.path).create(branch='master')
3066+
"fatal: a branch named 'master' already exists"
3067+
"""
3068+
return self.cmd.run(
3069+
[
3070+
"checkout",
3071+
*["-b", branch],
3072+
],
3073+
# Pass-through to run()
3074+
check_returncode=False,
3075+
)

0 commit comments

Comments
 (0)