Skip to content

Commit e25634b

Browse files
committed
feat(vcs): jj-aware git backend, incl. Jujutsu workspace support
Adds a `JjAwareGit` decorator that wraps the Git backend inside a Jujutsu workspace and routes working-copy/revision operations through jj. - Detect via `jj root`. - get_changed_files. - get_local_branch → bookmark at @ or short change-id. - get_local_branch_revision → @ commit id. - setup_hooks → still installs for git users, warns jj won't run them. - Everything else (file hashes/tree, repo root/slug) delegates to git. Auto-selected in session.rs when JjAwareGit::is_jj_workspace(). Plain-git checkouts and committed config are unaffected.
1 parent 20bae61 commit e25634b

3 files changed

Lines changed: 389 additions & 4 deletions

File tree

crates/app/src/session.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use moon_process::ProcessRegistry;
2424
use moon_project_graph::ProjectGraph;
2525
use moon_task_graph::TaskGraph;
2626
use moon_toolchain_plugin::*;
27-
use moon_vcs::{BoxedVcs, git::Git};
27+
use moon_vcs::{BoxedVcs, JjAwareGit, git::Git};
2828
use moon_workspace::{WorkspaceBuilder, WorkspaceBuilderAsync, WorkspaceBuilderContext};
2929
use moon_workspace_graph::WorkspaceGraph;
3030
use proto_core::ProtoEnvironment;
@@ -310,13 +310,23 @@ impl MoonSession {
310310
if self.vcs_adapter.get().is_none() {
311311
let config = &self.workspace_config.vcs;
312312

313-
let git: BoxedVcs = Box::new(Git::load(
313+
let git = Git::load(
314314
&self.workspace_root,
315315
&config.default_branch,
316316
&config.remote_candidates,
317-
)?);
317+
)?;
318+
319+
// Inside a Jujutsu workspace (colocated or secondary), wrap the Git
320+
// backend so working-copy/revision ops route through jj — correct
321+
// even in a secondary workspace, where git sees the parent repo.
322+
// Plain-git checkouts are unaffected.
323+
let vcs: BoxedVcs = if JjAwareGit::is_jj_workspace(&git) {
324+
Box::new(JjAwareGit::new(git))
325+
} else {
326+
Box::new(git)
327+
};
318328

319-
let _ = self.vcs_adapter.set(Arc::new(git));
329+
let _ = self.vcs_adapter.set(Arc::new(vcs));
320330
}
321331

322332
Ok(self.vcs_adapter.get().map(Arc::clone).unwrap())

0 commit comments

Comments
 (0)