Files
Ian AndersonandClaude Opus 4.8 948d731130 [update-checkout][test] Several utils/update_checkout/tests/test_cross_repo_pr.py tests request commit signing
Several of the tests in utils/update_checkout/tests/test_cross_repo_pr.py make commits without calling configure_git_identity to suppress commit signing. Most of them could be patched to do so, but test_checkout_stale_pr_merge_ref_during_clone and test_checkout_stale_pr_merge_ref_during_shallow_clone run `call` with both --clone and --github-comment. The latter ends up creating a merge commit to update the stale merge ref, which is what the tests are testing, and that can prompt the user for commit signing.

It would be difficult at best to try to optionally insert the configure_git_identity inside of `call` since it's running `update-checkout` via `subprocess`. Instead, set GIT_CONFIG_GLOBAL in the environment before running tests, and configure that to set the user info and disable commit signing.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 22:28:24 -07:00

71 lines
2.1 KiB
Python

import subprocess
import tempfile
from typing import List
import unittest
from pathlib import Path
from .scheme_mock import UPDATE_CHECKOUT_PATH
class TestStatusCommand(unittest.TestCase):
def call(self, args: List[str], cwd: Path):
subprocess.check_call(
args, cwd=cwd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL
)
def init_repo(self, path: Path, with_changes: bool):
self.call(args=["git", "init"], cwd=path)
(path / "file.txt").write_text("initial\n")
self.call(args=["git", "add", "file.txt"], cwd=path)
self.call(args=["git", "commit", "-m", "initial commit"], cwd=path)
if with_changes:
(path / "file.txt").write_text("modified\n")
def test_repositories_with_active_changes(self):
with tempfile.TemporaryDirectory() as tmpdir:
root = Path(tmpdir)
repo_1 = root / "repo_1"
repo_2 = root / "repo_2"
repo_1.mkdir()
repo_2.mkdir()
self.init_repo(repo_1, True)
self.init_repo(repo_2, True)
output = subprocess.run(
[UPDATE_CHECKOUT_PATH, "--source-root", str(root), "status"],
capture_output=True,
text=True,
).stdout
self.assertIn("The following repositories have active changes:", output)
self.assertIn(" - [repo_1] 1 active change", output)
self.assertIn(" - [repo_2] 1 active change", output)
def test_repositories_without_active_changes(self):
with tempfile.TemporaryDirectory() as tmpdir:
root = Path(tmpdir)
repo_1 = root / "repo_1"
repo_2 = root / "repo_2"
repo_1.mkdir()
repo_2.mkdir()
self.init_repo(repo_1, False)
self.init_repo(repo_2, False)
output = subprocess.run(
[UPDATE_CHECKOUT_PATH, "--source-root", str(root), "status"],
capture_output=True,
text=True,
).stdout
self.assertIn("No repositories have active changes.", output)
if __name__ == "__main__":
unittest.main()