(target: Path)
| 180 | |
| 181 | |
| 182 | def git_submodule_entries(target: Path) -> tuple[tuple[Path, str], ...]: |
| 183 | repository, pathspec = git_worktree_context(target) |
| 184 | staged = git_bytes(repository, "ls-files", "--stage", "-z", "--", pathspec) |
| 185 | if staged is None: |
| 186 | raise SystemExit("Could not inspect Git submodules in the selected working tree.") |
| 187 | entries = [] |
| 188 | for record in (item for item in staged.split(b"\0") if item): |
| 189 | try: |
| 190 | metadata, raw_path = record.split(b"\t", 1) |
| 191 | mode, object_id, _ = metadata.split(b" ", 2) |
| 192 | except ValueError as exc: |
| 193 | raise SystemExit( |
| 194 | "Could not inspect Git submodules in the selected working tree." |
| 195 | ) from exc |
| 196 | if mode != b"160000": |
| 197 | continue |
| 198 | entries.append((repository / os.fsdecode(raw_path), object_id.decode("ascii"))) |
| 199 | return tuple(entries) |
| 200 | |
| 201 | |
| 202 | def git_submodule_paths(target: Path) -> tuple[Path, ...]: |
no test coverage detected