27 lines
826 B
Python
Executable File
27 lines
826 B
Python
Executable File
#!/usr/bin/env python3
|
|
"""Action ``repo-commit`` (read-only): one commit of a repo as a DiffResult.
|
|
|
|
stdin ``{repo, sha}`` — ``repo`` a diff repo token (``project:<slug>``,
|
|
``service:<slug>``, ``super:_``) → ``DiffResult``, through the core's
|
|
``hub/diff/commit?repo=&sha=`` (a guest: their own projects only)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pathlib
|
|
import sys
|
|
|
|
sys.dont_write_bytecode = True
|
|
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent))
|
|
import _lib # noqa: E402
|
|
|
|
|
|
def main(p: dict) -> dict:
|
|
repo = p.get("repo")
|
|
if not (isinstance(repo, str) and _lib.REPO_RE.fullmatch(repo)):
|
|
raise _lib.Fail("repo must be project:<slug>, service:<slug> or super:_")
|
|
return _lib.hub_get("diff/commit", repo=repo, sha=_lib.sha_of(p))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
_lib.run(main)
|