From 67d9e2f7924d5c525ab4364107111dbe6c7be79b Mon Sep 17 00:00:00 2001 From: Matthieu Monsch Date: Wed, 6 Aug 2025 21:49:03 -0700 Subject: [PATCH] fix: support submodules in worktree --- src/git_draft/toolbox.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/git_draft/toolbox.py b/src/git_draft/toolbox.py index 04cc7e8..176af24 100644 --- a/src/git_draft/toolbox.py +++ b/src/git_draft/toolbox.py @@ -270,7 +270,7 @@ def _update_tree(sha: SHA, updates: Sequence[_TreeUpdate], repo: Repo) -> SHA: case _DeleteBlob(path): blob_shas[path.parent][path.name] = "" case _: - raise UnreachableError() + raise UnreachableError(f"Unexpected update: {update}") def visit_tree(sha: SHA, path: PurePosixPath) -> SHA: old_lines = null_delimited(repo.git("ls-tree", "-z", sha).stdout) @@ -288,8 +288,10 @@ def visit_tree(sha: SHA, path: PurePosixPath) -> SHA: case "tree": new_sha = visit_tree(old_sha, path / name) new_lines.append(f"040000 tree {new_sha}\t{name}") + case "commit": # Submodule + new_lines.append(line) case _: - raise UnreachableError() + raise UnreachableError(f"Unexpected line: {line}") for name, blob_sha in new_blob_shas.items(): if blob_sha: