MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / git_info

Function git_info

pipcl.py:2065–2090  ·  view source on GitHub ↗

Returns `(sha, comment, diff, branch)`, all items are str or None if not available. directory: Root of git checkout.

( directory)

Source from the content-addressed store, hash-verified

2063
2064
2065def git_info( directory):
2066 '''
2067 Returns `(sha, comment, diff, branch)`, all items are str or None if not
2068 available.
2069
2070 directory:
2071 Root of git checkout.
2072 '''
2073 sha, comment, diff, branch = None, None, None, None
2074 e, out = run(
2075 f'cd {directory} && (PAGER= git show --pretty=oneline|head -n 1 && git diff)',
2076 capture=1,
2077 check=0
2078 )
2079 if not e:
2080 sha, _ = out.split(' ', 1)
2081 comment, diff = _.split('\n', 1)
2082 e, out = run(
2083 f'cd {directory} && git rev-parse --abbrev-ref HEAD',
2084 capture=1,
2085 check=0
2086 )
2087 if not e:
2088 branch = out.strip()
2089 log1(f'git_info(): directory={directory!r} returning branch={branch!r} sha={sha!r} comment={comment!r}')
2090 return sha, comment, diff, branch
2091
2092
2093def git_items( directory, submodules=False):

Callers

nothing calls this directly

Calls 2

log1Function · 0.85
runFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…