INNER CODE UNIT · Python

_git

pineforge-4pass/pineforge-engine · benchmarks/check_provenance.py:85

    def _git(self, *args: str, text: bool = True) -> subprocess.CompletedProcess:
        return subprocess.run(["git", "-C", str(REPO), *args], capture_output=True, text=text)

    def bytes(self, path: str) -> bytes:
        self.reads.append(path)
        if path not in self._read:
            if self.rev:
                res = self._git("show", f"{self.rev}:{path}", text=False)
                if res.returncode:
                    raise Unsourced(f"{path} is not committed at {self.rev}")
                self._read[path] = res.stdout
            elif self._git("ls-files", "--error-unmatch", path).returncode or not (REPO / path).is_file():
                raise Unsourced(f"{path} is not committed")
            else:
                self._read[path] = (REPO / path).read_bytes()
        return self._read[path]

    def text(self, path: str) -> str:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…