Skip to content

Commit f089b03

Browse files
committed
fix: parse reponame from https url
1 parent 1f3cd41 commit f089b03

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

alpa/repository/base.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,18 @@ def push(self, branch: str) -> None:
261261
# you always want to push to origin, even from a fork
262262
click.echo(self.git_cmd(["push", ORIGIN_NAME, branch]).stdout)
263263

264+
@staticmethod
265+
def _parse_reponame_from_url(url: str) -> str:
266+
without_git_suffix = url.removesuffix(".git")
267+
if without_git_suffix.startswith("https://") or without_git_suffix.startswith(
268+
"http://"
269+
):
270+
logger.info(f"Git remote url is in https form {without_git_suffix}")
271+
split = without_git_suffix.split("/")
272+
return f"{split[-2]}/{split[-1]}"
273+
274+
return url.split(":")[-1]
275+
264276
def full_reponame(self) -> str:
265277
logger.debug(f"Trying to find {self.remote_name} in {self.remotes}")
266278
for remote in self.remotes:
@@ -271,7 +283,7 @@ def full_reponame(self) -> str:
271283
logger.debug(
272284
f"Remote {remote} found. Parsing its remote url {remote_url}"
273285
)
274-
return remote_url.split(":")[-1].removesuffix(".git")
286+
return self._parse_reponame_from_url(remote_url)
275287

276288
logger.debug("There are no remotes in this repo")
277289
return ""

0 commit comments

Comments
 (0)