Skip to content

Commit 5220b76

Browse files
authored
Update delete_remote_branches to also use branch name template. (#37)
1 parent 79d6dde commit 5220b76

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/stack_pr/cli.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,16 +1035,18 @@ def delete_local_branches(st: List[StackEntry], verbose: bool):
10351035
run_shell_command(cmd, check=False, quiet=not verbose)
10361036

10371037

1038-
def delete_remote_branches(st: List[StackEntry], remote: str, verbose: bool):
1038+
def delete_remote_branches(
1039+
st: List[StackEntry], remote: str, verbose: bool, branch_name_template: str
1040+
):
10391041
log(h("Deleting remote branches"), level=1)
10401042
run_shell_command(["git", "fetch", "--prune", remote], quiet=not verbose)
10411043

1042-
username = get_gh_username()
1044+
branch_name_base = get_branch_name_base(branch_name_template)
10431045
refs = get_command_output(
10441046
[
10451047
"git",
10461048
"for-each-ref",
1047-
f"refs/remotes/{remote}/{username}/stack",
1049+
f"refs/remotes/{remote}/{branch_name_base}",
10481050
"--format=%(refname)",
10491051
]
10501052
).split()
@@ -1111,7 +1113,9 @@ def command_land(args: CommonArgs):
11111113
)
11121114

11131115
delete_local_branches(st, args.verbose)
1114-
delete_remote_branches(st[:1], args.remote, args.verbose)
1116+
delete_remote_branches(
1117+
st[:1], args.remote, args.verbose, args.branch_name_template
1118+
)
11151119

11161120
# If local branch {target} exists, rebase it on the remote/target
11171121
if branch_exists(args.target):
@@ -1177,7 +1181,9 @@ def command_abandon(args: CommonArgs):
11771181
)
11781182

11791183
delete_local_branches(st, args.verbose)
1180-
delete_remote_branches(st, args.remote, args.verbose)
1184+
delete_remote_branches(
1185+
st, args.remote, args.verbose, args.branch_name_template
1186+
)
11811187
log(h(blue("SUCCESS!")), level=1)
11821188

11831189

0 commit comments

Comments
 (0)