Skip to content

Commit

Permalink
git: Correctly match repository names containing '.'
Browse files Browse the repository at this point in the history
The '.' character is valid in repository names on github. Change the
regexes to use negative lookbehind assertions to avoid matching an
optional trailing '.git' instead of stopping the repository name when
encountering '.'.

Without this, revup cannot be used on repositories containing the '.'
character.

Signed-off-by: Brian Kubisiak <[email protected]>
  • Loading branch information
velentr committed Dec 2, 2024
1 parent d29851a commit 11ffd9c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions revup/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,13 @@ async def get_github_repo_info(self, github_url: str, remote_name: str) -> GitHu
return GitHubRepoInfo(owner=owner, name=name)
remote_url = ret[1]
while True:
match = rf"^[^@]+@{github_url}:([^/]+)/([^.]+)(?:\.git)?$"
match = rf"^[^@]+@{github_url}:([^/]+)/(.+)(?<!\.git)(?:\.git)?$"
m = re.match(match, remote_url)
if m:
owner = m.group(1)
name = m.group(2)
break
search = rf"{github_url}/([^/]+)/([^.]+)"
search = rf"{github_url}/([^/]+)/(.+)(?<!\.git)(?:\.git)?$"
m = re.search(search, remote_url)
if m:
owner = m.group(1)
Expand Down

0 comments on commit 11ffd9c

Please sign in to comment.