diff --git a/lando_cli/cli.py b/lando_cli/cli.py index 137ff7a..06b84f6 100644 --- a/lando_cli/cli.py +++ b/lando_cli/cli.py @@ -373,7 +373,9 @@ def display_add_commit_actions( click.echo(f"About to push {len(actions)} commits.") # Use the last patch as the tip commit - last_patch = base64.b64decode(actions[-1]["content"]).decode("utf-8") + last_patch = base64.b64decode(actions[-1]["content"]).decode( + "utf-8", errors="surrogateescape" + ) first_line = last_patch.splitlines()[0] if first_line.startswith("From "): diff --git a/tests/test_click.py b/tests/test_click.py index 33b03fe..3124f67 100644 --- a/tests/test_click.py +++ b/tests/test_click.py @@ -40,17 +40,25 @@ def mock_submit_to_lando(monkeypatch: pytest.MonkeyPatch) -> mock.Mock: return mock_fixture +@pytest.mark.parametrize( + "commit_data", + ( + "just a string", + b"-\x1f\x8b\n", # GZip magic bytes + ), +) def test_push_commits( git_local_repo: Path, create_commit: Callable, mock_get_repo_info: mock.Mock, mock_submit_to_lando: mock.Mock, + commit_data: bytes | str, ): commit_message = "New commit to push" runner = CliRunner() with runner.isolated_filesystem(git_local_repo): - create_commit(commit_message=commit_message) + create_commit(commit_data, commit_message=commit_message) result = runner.invoke(cli.push_commits, ["--yes"]) assert result.exit_code == 0