import logging
import os
import subprocess
+import sys
from typing import Tuple
subprocess.run(['git', '-C', cachedir, 'cat-file', '-e', rev], check=True)
return cachedir
+
+
+def _main() -> None:
+ if len(sys.argv) == 3:
+ print('{1} {0}'.format(*fetch(Repo(sys.argv[1]), Ref(sys.argv[2]))))
+ elif len(sys.argv) == 4:
+ print(ensure_rev_available(
+ Repo(sys.argv[1]), Ref(sys.argv[2]), Rev(sys.argv[3])))
+ else:
+ usage = '''usage: git-cache repo ref [rev]
+example: git-cache https://github.com/NixOS/nixpkgs.git master'''
+ print(usage, file=sys.stderr)
+ sys.exit(1)
setup(
name="git_cache",
version="0.0.1-pre",
+ entry_points={'console_scripts': ['git-cache = git_cache:_main']},
py_modules=['git_cache'],
)