fix: deploy verify parsing must ignore ssh warning lines (#55)

Co-authored-by: host <host@test.local>
This commit is contained in:
openqjandhost authored and GitHub committed 2026-10-27 00:41:40 +08:00
1 parent 32125f7a98
commit 84ff968111
2 files changed
+45 -2

No files matched your search

+29
View File
@@ -9,6 +9,7 @@ import sys
import tarfile
import tempfile
import unittest
from unittest import mock
REPO_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(
os.path.abspath(__file__))))
@@ -52,6 +53,34 @@ class TestDeployPure(unittest.TestCase):
finally:
os.unlink(path)
def test_remote_sha_ignores_ssh_warning_lines(self):
# 2026-10-27 新链路首推实测:pty helper 把 ssh 的 Warning 行
# 合并进 stdout 放在 sha 行前面,旧 split()[0] 取到 Warning:
# 导致传输明明成功却被判验真失败、两路都“失败”。
sha = "5d0645b85a65b2d58d0d5812f9e8020bdafe15d60dc440e763cfcc7cd178148b"
fake = subprocess.CompletedProcess(
args=[], returncode=0,
stdout="Warning: Permanently added 'x' (ED25519) to the list of known hosts.\n"
+ sha + " /tmp/x.tar.gz\n", stderr="")
with mock.patch.object(deploy_mod.subprocess, "run",
return_value=fake):
self.assertEqual(deploy_mod.remote_sha("h", "u", "/tmp/x"), sha)
def test_remote_sha_none_without_hash(self):
fake = subprocess.CompletedProcess(args=[], returncode=0,
stdout="Warning: something\n",
stderr="")
with mock.patch.object(deploy_mod.subprocess, "run",
return_value=fake):
self.assertIsNone(deploy_mod.remote_sha("h", "u", "/tmp/x"))
def test_live_commit_ignores_ssh_warning_lines(self):
commit = "32125f7a980e24fd28664a60701d7c1123beb63e"
out = "Warning: Permanently added 'x' (ED25519) to the list of known hosts.\n" \
+ commit + "\n"
self.assertEqual(deploy_mod.live_commit(out), commit)
self.assertIsNone(deploy_mod.live_commit("Warning: something\n"))
class TestBuildRelease(unittest.TestCase):
def test_build_from_temp_git_repo(self):