MCPcopy Index your code
hub / github.com/pymupdf/PyMuPDF / git_items

Function git_items

pipcl.py:2093–2129  ·  view source on GitHub ↗

Returns list of paths for all files known to git within a `directory`. Args: directory: Must be somewhere within a git checkout. submodules: If true we also include git submodules. Returns: A list of paths for all files known to git with

( directory, submodules=False)

Source from the content-addressed store, hash-verified

2091
2092
2093def git_items( directory, submodules=False):
2094 '''
2095 Returns list of paths for all files known to git within a `directory`.
2096
2097 Args:
2098 directory:
2099 Must be somewhere within a git checkout.
2100 submodules:
2101 If true we also include git submodules.
2102
2103 Returns:
2104 A list of paths for all files known to git within `directory`. Each
2105 path is relative to `directory`. `directory` must be somewhere within a
2106 git checkout.
2107
2108 We run a `git ls-files` command internally.
2109
2110 This function can be useful for the `fn_sdist()` callback.
2111 '''
2112 command = 'cd ' + directory + ' && git ls-files'
2113 if submodules:
2114 command += ' --recurse-submodules'
2115 log1(f'Running {command=}')
2116 text = subprocess.check_output( command, shell=True)
2117 ret = []
2118 for path in text.decode('utf8').strip().split( '\n'):
2119 path2 = os.path.join(directory, path)
2120 # Sometimes git ls-files seems to list empty/non-existent directories
2121 # within submodules.
2122 #
2123 if not os.path.exists(path2):
2124 log2(f'Ignoring git ls-files item that does not exist: {path2}')
2125 elif os.path.isdir(path2):
2126 log2(f'Ignoring git ls-files item that is actually a directory: {path2}')
2127 else:
2128 ret.append(path)
2129 return ret
2130
2131
2132def git_get(

Callers

nothing calls this directly

Calls 3

log1Function · 0.85
log2Function · 0.85
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…