Something went wrong. Try again.
A local Git merge queue with content-bound gate verdicts
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445"""Pin git-config(1) rewrites of complete mq dependency declarations."""import csvimport pathlibimport subprocessimport sysimport tempfile
OLD = b"a" * 40PATH_URL = b"path=vendor/lib\nurl=https://example.org/lib.git\n"CASES = { "comments": b'# before\n[dependency "lib"]\n path=vendor/lib\n' b' url=https://example.org/lib.git\n commit="' + OLD + b'" # old\n# footer\n', "inline-header": b'[dependency "lib"] commit=' + OLD + b'\n' + PATH_URL, "crlf": b'[dependency "lib"]\r\n path=vendor/lib\r\n' b' url=https://example.org/lib.git\r\n commit=' + OLD + b'\r\n', "continued-value": b'[dependency "lib"]\ncommit=' + OLD[:20] + b'\\\n' + OLD[20:] + b'\n' + PATH_URL, "header-comment": b' [dependency "lib"] # declaration\n commit=' + OLD + b'\n' + PATH_URL, "other-sections": b'[core]\nflag\n[dependency "other"]\npath=vendor/other\n' b'url=https://example.org/other.git\ncommit=' + OLD + b'\n' b'[dependency "lib"]\ncommit=' + OLD + b'\n' + PATH_URL,}
def main(): output = pathlib.Path(sys.argv[1]) pinned = pathlib.Path(__file__).with_name("git-version").read_text().strip() version = subprocess.check_output(["git", "--version"], text=True).strip() if version.split()[2] != pinned: raise SystemExit(f"regeneration needs Git {pinned}; found {version}") (output / "git-version").write_text(f"git version {pinned}\n") with tempfile.TemporaryDirectory() as directory: config = pathlib.Path(directory) / ".mqmodule" with (output / "edits.csv").open("w", newline="") as stream: writer = csv.writer(stream, lineterminator="\n") writer.writerow(["name", "input_hex", "dependency", "commit", "output_hex"]) for name, contents in CASES.items(): config.write_bytes(contents) selected = "b" * 40 subprocess.run(["git", "config", "-f", str(config), "dependency.lib.commit", selected], check=True) writer.writerow([name, contents.hex(), "lib", selected, config.read_bytes().hex()])
if __name__ == "__main__": main()