fix(bundles): snapshot the revision bytes regardless of builder eol config
(cherry picked from commit e5548831796d3223f37a1dc65b274fd07103b35e)
This commit is contained in:
@@ -38,8 +38,13 @@ def snapshot(repo: Path, ref: str, destination: Path, exclude: tuple[str, ...] =
|
||||
with tempfile.TemporaryDirectory(prefix="hermes-archive-") as temp:
|
||||
archive = Path(temp) / "source.tar"
|
||||
pathspecs = [f":(exclude){name}" for name in exclude]
|
||||
# git archive applies checkout eol conversion. Git for Windows sets
|
||||
# core.autocrlf=true system-wide, which would rewrite every text file
|
||||
# lacking an eol attribute to CRLF: the payload must carry the
|
||||
# revision's bytes (plus .gitattributes rules), not builder config.
|
||||
subprocess.run(
|
||||
["git", "archive", "--format=tar", "--output", str(archive), ref, "--", *pathspecs],
|
||||
["git", "-c", "core.autocrlf=false", "-c", "core.eol=lf",
|
||||
"archive", "--format=tar", "--output", str(archive), ref, "--", *pathspecs],
|
||||
cwd=repo, check=True)
|
||||
if destination.exists():
|
||||
shutil.rmtree(destination)
|
||||
|
||||
@@ -22,6 +22,26 @@ def test_release_version_comes_from_the_release_identity_not_the_checkout(tmp_pa
|
||||
assert release_version(tmp_path, "v1.2.4") == "1.2.4"
|
||||
|
||||
|
||||
def test_snapshot_carries_revision_bytes_regardless_of_builder_eol_config(tmp_path):
|
||||
# Git for Windows ships core.autocrlf=true system-wide; set it on the
|
||||
# fixture repo so every platform exercises the same builder config.
|
||||
repo = tmp_path / "repo"
|
||||
repo.mkdir()
|
||||
git = ["git", "-c", "user.name=Fixture", "-c", "user.email=fixture@example.test"]
|
||||
subprocess.run(["git", "init", "-q", str(repo)], check=True)
|
||||
subprocess.run(["git", "config", "core.autocrlf", "true"], cwd=repo, check=True)
|
||||
(repo / ".gitattributes").write_bytes(b"*.ps1 text eol=crlf\n")
|
||||
(repo / "plain.json").write_bytes(b'{\n"a": 1\n}\n')
|
||||
(repo / "script.ps1").write_bytes(b"one\ntwo\n")
|
||||
subprocess.run([*git, "add", "."], cwd=repo, check=True, capture_output=True)
|
||||
subprocess.run([*git, "commit", "-qm", "fixture"], cwd=repo, check=True)
|
||||
out = tmp_path / "out"
|
||||
snapshot(repo, "HEAD", out)
|
||||
assert (out / "plain.json").read_bytes() == b'{\n"a": 1\n}\n'
|
||||
# Committed eol attributes still apply: only builder config is ignored.
|
||||
assert (out / "script.ps1").read_bytes() == b"one\r\ntwo\r\n"
|
||||
|
||||
|
||||
def test_wrapper_rejects_unresolved_template_fields(tmp_path, monkeypatch):
|
||||
from scripts.build import launchers
|
||||
|
||||
|
||||
Reference in New Issue
Block a user