Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style(remote): reword git error messages #4536

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion snapcraft/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,12 @@ def run(): # noqa: C901 (complex-structure)
emit.error(craft_cli.errors.CraftError(f"linter error: {err}"))
retcode = err.exit_code
except RemoteBuildError as err:
emit.error(craft_cli.errors.CraftError(f"remote-build error: {err}"))
emit.error(
craft_cli.errors.CraftError(
message=f"remote-build error: {err}",
docs_url="https://snapcraft.io/docs/remote-build",
)
)
retcode = 1
except errors.SnapcraftError as err:
_emit_error(err)
Expand Down
2 changes: 0 additions & 2 deletions snapcraft/remote/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ def __init__(self) -> None:
class RemoteBuildFailedError(RemoteBuildError):
"""Remote build failed.

:param brief: Brief description of error.
:param details: Detailed information.
"""

Expand All @@ -120,7 +119,6 @@ def __init__(self, details: str) -> None:
class RemoteBuildInvalidGitRepoError(RemoteBuildError):
"""The Git repository is invalid for remote build.

:param brief: Brief description of error.
:param details: Detailed information.
"""

Expand Down
6 changes: 4 additions & 2 deletions snapcraft/remote/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,14 @@ def check_git_repo_for_remote_build(path: Path) -> None:

if git_type == GitType.INVALID:
raise RemoteBuildInvalidGitRepoError(
f"Could not find a git repository in {str(path)!r}"
f"Could not find a git repository in {str(path.absolute())!r}. "
"The project must be in the top-level of a git repository."
)

if git_type == GitType.SHALLOW:
raise RemoteBuildInvalidGitRepoError(
"Remote build for shallow cloned git repos are no longer supported"
"Remote builds are not supported for projects in shallowly cloned "
"git repositories."
mr-cal marked this conversation as resolved.
Show resolved Hide resolved
)


Expand Down
5 changes: 4 additions & 1 deletion tests/unit/commands/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,10 @@ def test_run_in_shallow_repo_unsupported(capsys, new_dir):
assert ret != 0
_, err = capsys.readouterr()

assert "Remote build for shallow cloned git repos are no longer supported" in err
assert (
"Remote builds are not supported for projects in shallowly cloned "
"git repositories."
) in err


######################
Expand Down
11 changes: 9 additions & 2 deletions tests/unit/remote/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,11 @@ def test_push_url_push_error(new_dir):
def test_check_git_repo_for_remote_build_invalid(new_dir):
"""Check if directory is an invalid repo."""
with pytest.raises(
RemoteBuildInvalidGitRepoError, match="Could not find a git repository in"
RemoteBuildInvalidGitRepoError,
match=(
f"Could not find a git repository in {str(new_dir.absolute())!r}. "
"The project must be in the top-level of a git repository."
),
):
check_git_repo_for_remote_build(new_dir)

Expand Down Expand Up @@ -584,6 +588,9 @@ def test_check_git_repo_for_remote_build_shallow(new_dir):

with pytest.raises(
RemoteBuildInvalidGitRepoError,
match="Remote build for shallow cloned git repos are no longer supported",
match=(
"Remote builds are not supported for projects in shallowly cloned "
"git repositories."
),
):
check_git_repo_for_remote_build(git_shallow_path)