def METHOD_NAME(repo: git.Repo):
    """Patch files corresponding to non-adjacent commits, which should be squashed
    by name are not squashed and an exception is raised."""
    readme = Path(repo.working_dir, "README.md")
    readme.write_text(f"{readme.read_text()}\nThe first change.\n")
    repo.git.add("README.md")
    commit_message = textwrap.dedent(
        """\
        First commit
        patch_name: non_adjacent.patch
        """
    )
    repo.git.commit(f"-m{commit_message}")
    readme = Path(repo.working_dir, "README.md")
    readme.write_text(f"{readme.read_text()}\nThe second change.\n")
    repo.git.add("README.md")
    commit_message = "Second commit"
    repo.git.commit(f"-m{commit_message}")
    readme = Path(repo.working_dir, "README.md")
    readme.write_text(f"{readme.read_text()}\nThe third change.\n")
    repo.git.add("README.md")
    commit_message = textwrap.dedent(
        """\
        Third commit
        patch_name: non_adjacent.patch
        """
    )
    repo.git.commit(f"-m{commit_message}")