Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions revup/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ async def get_editor() -> str:
'Branch {} not found, falling back to "{}". We recommend you set this in'
" .revupconfig".format(main_branch, git_ctx.main_branch)
)

await git_ctx.check_remote_exists()

return git_ctx


Expand Down Expand Up @@ -305,6 +308,17 @@ async def git_return_code(self, *args: str, **kwargs: Any) -> int:
async def git_stdout(self, *args: str, **kwargs: Any) -> str:
return (await self.git(*args, **kwargs))[1]

async def check_remote_exists(self) -> None:
"""Verify the configured remote exists, raise helpful error if not."""
remote_exists = await self.git_return_code(
"remote", "get-url", self.remote_name
) == 0
if not remote_exists:
raise RevupUsageException(
f"Remote '{self.remote_name}' not found.\n"
"Revup requires a remote to determine the base branch.\n"
)

async def get_github_repo_info(self, github_url: str, remote_name: str) -> GitHubRepoInfo:
"""
Return github repo's name and owner.
Expand Down