gabriel / muse public
feat BREAKING feat/code-migrate #1 / 1
gabriel · 162 days ago · Apr 9, 2026 · Diff

feat: add muse code migrate command

Replaces tools/git2muse.py with a first-class CLI command under muse code.

New: muse/cli/commands/migrate.py - SOURCE positional arg (defaults to CWD) - --target PATH migrate into a separate directory - --branch BRANCH [...] replay specific branches - --all replay every local branch (main first) - --from-ref SHA incremental mode: only commits newer than this SHA - --exclude PATTERN [...] extra exclusion patterns beyond built-in defaults - --no-init skip auto muse-init when target already has .muse/ - --dry-run preview without writing - --verbose log every commit - --json structured JSON report with per-branch stats and elapsed time

Deleted: tools/git2muse.py (superseded) Updated: muse/cli/app.py — import + registration under code_subs

sha256:d357c7e09f9e4872fea93293535d69ac16f1a5e4bb8a9855891091e3aa260c36 sha
+47 ~106 −45 symbols
sha256:497390822842b6633e173ab07809acf59ddecd2494e570fe032a47eadd97fc5f snapshot
+47
symbols added
~106
symbols modified
−45
symbols removed
0
dead code introduced
Semantic Changes 198 symbols
~ muse/cli/commands/migrate.py .py 46 symbols added
+ _DEFAULT_EXCLUDE_PREFIXES variable variable _DEFAULT_EXCLUDE_PREFIXES L83–96
+ _DEFAULT_EXCLUDE_SUFFIXES variable variable _DEFAULT_EXCLUDE_SUFFIXES L98–107
+ _META_SEP variable variable _META_SEP L131–131 ← moved from tools/git2muse.py
+ _ensure_branch_exists function function _ensure_branch_exists L275–279
+ _extract_tree_to function function _extract_tree_to L214–250
+ _get_branch_head function function _get_branch_head L268–272
+ _git function function _git L134–143 ← moved from tools/git2muse.py
+ _git_commit_meta function function _git_commit_meta L173–186
+ _git_commits_oldest_first function function _git_commits_oldest_first L146–170
+ _git_is_repo function function _git_is_repo L205–211
+ _git_local_branches function function _git_local_branches L199–202 ← moved from tools/git2muse.py
+ _git_parent_shas function function _git_parent_shas L189–192 ← moved from tools/git2muse.py
+ _is_merge_commit function function _is_merge_commit L195–196 ← moved from tools/git2muse.py
+ _load_repo_id function function _load_repo_id L282–285
+ _refs_dir function function _refs_dir L258–259
+ _replay_branch function function _replay_branch L360–412
+ _replay_commit function function _replay_commit L293–357
+ _set_branch_head function function _set_branch_head L262–265
+ _should_exclude function function _should_exclude L110–124
+ CommitRecord import import CommitRecord L69–69
+ SnapshotRecord import import SnapshotRecord L69–69
+ annotations import import annotations L50–50 ← moved from tools/git2muse.py
+ append_reflog import import append_reflog L66–66 ← moved from tools/git2muse.py
+ argparse import import argparse L52–52 ← moved from tools/git2muse.py
+ compute_commit_id import import compute_commit_id L68–68
+ compute_snapshot_id import import compute_snapshot_id L68–68
+ datetime import import datetime L53–53 ← moved from tools/git2muse.py
+ json import import json L54–54
+ logging import import logging L55–55 ← moved from tools/git2muse.py
+ os import import os L56–56
+ pathlib import import pathlib L57–57 ← moved from tools/git2muse.py
+ require_repo import import require_repo L67–67
+ shutil import import shutil L58–58 ← moved from tools/git2muse.py
+ subprocess import import subprocess L59–59 ← moved from tools/git2muse.py
+ sys import import sys L60–60 ← moved from tools/git2muse.py
+ tarfile import import tarfile L61–61 ← moved from tools/git2muse.py
+ tempfile import import tempfile L62–62 ← moved from tools/git2muse.py
+ time import import time L63–63
+ walk_workdir_with_dirs import import walk_workdir_with_dirs L68–68 ← moved from tools/git2muse.py
+ write_commit import import write_commit L69–69
+ write_head_branch import import write_head_branch L69–69
+ write_object import import write_object L65–65 ← moved from tools/git2muse.py
+ write_snapshot import import write_snapshot L69–69
+ logger variable variable logger L77–77
+ register function function register L420–527
+ run function function run L530–701
~ tools/git2muse.py .py 45 symbols removed
_EXCLUDE_PREFIXES variable variable _EXCLUDE_PREFIXES L77–88
_EXCLUDE_SUFFIXES variable variable _EXCLUDE_SUFFIXES L90–99
_META_SEP variable variable _META_SEP L151–151 → moved to muse/cli/commands/migrate.py
_REPO_ROOT variable variable _REPO_ROOT L50–50
_build_manifest_with_dirs function function _build_manifest_with_dirs L228–241
_ensure_branch_exists function function _ensure_branch_exists L287–291
_extract_tree_to function function _extract_tree_to L186–220
_get_branch_head function function _get_branch_head L276–280
_git function function _git L118–127 → moved to muse/cli/commands/migrate.py
_git_commit_meta function function _git_commit_meta L154–167
_git_commits_oldest_first function function _git_commits_oldest_first L130–148
_git_local_branches function function _git_local_branches L180–183 → moved to muse/cli/commands/migrate.py
_git_parent_shas function function _git_parent_shas L170–173 → moved to muse/cli/commands/migrate.py
_is_merge_commit function function _is_merge_commit L176–177 → moved to muse/cli/commands/migrate.py
_load_repo_id function function _load_repo_id L431–435
_refs_dir function function _refs_dir L264–265
_replay_branch function function _replay_branch L373–423
_replay_commit function function _replay_commit L299–370
_set_branch_head function function _set_branch_head L268–273
_set_head_ref function function _set_head_ref L283–284
_should_exclude function function _should_exclude L102–110
_store_objects function function _store_objects L244–256
CommitRecord import import CommitRecord L56–56
SnapshotRecord import import SnapshotRecord L56–56
annotations import import annotations L34–34 → moved to muse/cli/commands/migrate.py
append_reflog import import append_reflog L55–55 → moved to muse/cli/commands/migrate.py
argparse import import argparse L36–36 → moved to muse/cli/commands/migrate.py
compute_commit_id import import compute_commit_id L64–64
compute_snapshot_id import import compute_snapshot_id L64–64
datetime import import datetime L37–37 → moved to muse/cli/commands/migrate.py
get_head_commit_id import import get_head_commit_id L56–56
logging import import logging L38–38 → moved to muse/cli/commands/migrate.py
pathlib import import pathlib L39–39 → moved to muse/cli/commands/migrate.py
shutil import import shutil L40–40 → moved to muse/cli/commands/migrate.py
subprocess import import subprocess L41–41 → moved to muse/cli/commands/migrate.py
sys import import sys L42–42 → moved to muse/cli/commands/migrate.py
tarfile import import tarfile L43–43 → moved to muse/cli/commands/migrate.py
tempfile import import tempfile L44–44 → moved to muse/cli/commands/migrate.py
walk_workdir_with_dirs import import walk_workdir_with_dirs L64–64 → moved to muse/cli/commands/migrate.py
write_commit import import write_commit L56–56
write_head_branch import import write_head_branch L56–56
write_object import import write_object L54–54 → moved to muse/cli/commands/migrate.py
write_snapshot import import write_snapshot L56–56
logger variable variable logger L70–70
main function function main L438–572
← Older Oldest on feat/code-migrate
All commits
Newer → Latest on feat/code-migrate

0 comments

No comments yet. Be the first to start the discussion.

To add a comment, use the Muse CLI: muse hub commit comment sha256:d357c7e09f9e4872fea93293535d69ac16f1a5e4bb8a9855891091e3aa260c36 --body "your comment"