Skip to content

Commit a3b909e

Browse files
resolve $BRANCH branch as current branch name if provided in branch_name_template (#40)
1 parent 7cbd8ab commit a3b909e

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,4 @@ venv.bak/
8484
pixi.lock
8585

8686
.stack-pr.cfg
87+
.vscode

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,5 +258,5 @@ keep_body=False
258258
remote=origin
259259
target=main
260260
reviewer=GithubHandle1,GithubHandle2
261-
branch_name_template=$USERNAME/stack
261+
branch_name_template=$USERNAME/$BRANCH
262262
```

src/stack_pr/cli.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import re
5555
from functools import cache
5656
from subprocess import SubprocessError
57+
from typing import List, NamedTuple, Optional, Pattern
5758

5859
from stack_pr.git import (
5960
branch_exists,
@@ -67,7 +68,6 @@
6768
run_shell_command,
6869
set_show_commands,
6970
)
70-
from typing import List, NamedTuple, Optional, Pattern
7171

7272
# A bunch of regexps for parsing commit messages and PR descriptions
7373
RE_RAW_COMMIT_ID = re.compile(r"^(?P<commit>[a-f0-9]+)$", re.MULTILINE)
@@ -565,7 +565,9 @@ def add_or_update_metadata(
565565
@cache
566566
def get_branch_name_base(branch_name_template: str):
567567
username = get_gh_username()
568+
current_branch_name = get_current_branch_name()
568569
branch_name_base = branch_name_template.replace("$USERNAME", username)
570+
branch_name_base = branch_name_template.replace("$BRANCH",current_branch_name)
569571
return branch_name_base
570572

571573

@@ -1388,6 +1390,7 @@ def main():
13881390
check_gh_installed()
13891391

13901392
current_branch = get_current_branch_name()
1393+
get_branch_name_base(common_args.branch_name_template)
13911394
try:
13921395
if args.command != "view" and not is_repo_clean():
13931396
error(ERROR_REPO_DIRTY)

0 commit comments

Comments
 (0)