INNER CODE UNIT · Python

commit

spantaleev/matrix-docker-ansible-deploy · bin/molecule-select-roles.py:51

    def commit(self, ref):
        return self.run("rev-parse", "--verify", "--end-of-options", f"{ref}^{{commit}}").decode().strip()

    def snapshot(self, ref):
        entries = {}
        for entry in self.run("ls-tree", "-rz", ref, "--", "roles/custom", "molecule-shared").split(b"\0"):
            if not entry:
                continue
            metadata, path = entry.decode().split("\t", 1)
            mode, kind, oid = metadata.split()
            if path.startswith("molecule-shared/") or "/molecule/" in path:
                if kind != "blob":
                    raise Uncertain(f"Unsupported Git entry: {path}")
                entries[path] = (mode, oid)

        # Read the blobs in one process; a subprocess per scenario file is slow.
        oids = list(dict.fromkeys(oid for mode, oid in entries.values()))
        data = self.run("cat-file", "--batch", input="".join(f"{oid}\n" for oid in oids).encode())

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…