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

Function git_info

setup.py:368–395  ·  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

366
367
368def git_info( directory):
369 '''
370 Returns `(sha, comment, diff, branch)`, all items are str or None if not
371 available.
372
373 directory:
374 Root of git checkout.
375 '''
376 sha, comment, diff, branch = '', '', '', ''
377 cp = subprocess.run(
378 f'cd {directory} && (PAGER= git show --pretty=oneline|head -n 1 && git diff)',
379 capture_output=1,
380 shell=1,
381 text=1,
382 )
383 if cp.returncode == 0:
384 sha, _ = cp.stdout.split(' ', 1)
385 comment, diff = _.split('\n', 1)
386 cp = subprocess.run(
387 f'cd {directory} && git rev-parse --abbrev-ref HEAD',
388 capture_output=1,
389 shell=1,
390 text=1,
391 )
392 if cp.returncode == 0:
393 branch = cp.stdout.strip()
394 log(f'git_info(): directory={directory!r} returning branch={branch!r} sha={sha!r} comment={comment!r}')
395 return sha, comment, diff, branch
396
397
398def git_patch(directory, patch, hard=False):

Callers 1

buildFunction · 0.70

Calls 2

logFunction · 0.70
runMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…