Skip to content

Commit

Permalink
resolve $BRANCH branch as current branch name if provided in branch_n…
Browse files Browse the repository at this point in the history
…ame_template (#40)
  • Loading branch information
GiorgosAlexakis authored Oct 17, 2024
1 parent 7cbd8ab commit a3b909e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,4 @@ venv.bak/
pixi.lock

.stack-pr.cfg
.vscode
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,5 +258,5 @@ keep_body=False
remote=origin
target=main
reviewer=GithubHandle1,GithubHandle2
branch_name_template=$USERNAME/stack
branch_name_template=$USERNAME/$BRANCH
```
5 changes: 4 additions & 1 deletion src/stack_pr/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import re
from functools import cache
from subprocess import SubprocessError
from typing import List, NamedTuple, Optional, Pattern

from stack_pr.git import (
branch_exists,
Expand All @@ -67,7 +68,6 @@
run_shell_command,
set_show_commands,
)
from typing import List, NamedTuple, Optional, Pattern

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


Expand Down Expand Up @@ -1388,6 +1390,7 @@ def main():
check_gh_installed()

current_branch = get_current_branch_name()
get_branch_name_base(common_args.branch_name_template)
try:
if args.command != "view" and not is_repo_clean():
error(ERROR_REPO_DIRTY)
Expand Down

0 comments on commit a3b909e

Please sign in to comment.