Skip to content

Commit 79557e0

Browse files
committed
Tighten GITHUB_BRANCH_PATTERN to reject malformed refs
Repository names could previously contain a slash and branches could be empty, which produced bogus GitHubBranch values instead of a clear parse error. Addresses CodeRabbit review comment on PR #71.
1 parent c1b92b3 commit 79557e0

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

rebasebot/github.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from github import Auth, Github, GithubIntegration, UnknownObjectException
2323

2424
logger = logging.getLogger()
25-
GITHUB_BRANCH_PATTERN = re.compile(r"^(?P<organization>[^/]+)/(?P<name>[^:]+):(?P<branch>.*)$")
25+
GITHUB_BRANCH_PATTERN = re.compile(r"^(?P<organization>[^/:]+)/(?P<name>[^/:]+):(?P<branch>[^:]+)$")
2626

2727

2828
@dataclass

tests/test_cli.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ def test_github_branch_parse_valid(self, get_valid_cli_args, arg, github_ref, ex
101101
"/kubernetes/autoscaler:master",
102102
"fooo",
103103
"asdasdasdqwe/asdasd\\asdsadasd",
104+
"kubernetes/auto/scaler:master",
105+
"kubernetes/autoscaler:",
104106
),
105107
)
106108
@pytest.mark.parametrize("arg", ["source", "dest", "rebase"])

0 commit comments

Comments
 (0)