Skip to content

Commit 031d471

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 e0622f1 commit 031d471

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
@@ -19,7 +19,7 @@ use moon_process::ProcessRegistry;
1919
use moon_project_graph::ProjectGraph;
2020
use moon_task_graph::TaskGraph;
2121
use moon_toolchain_plugin::*;
22-
use moon_vcs::{BoxedVcs, git::Git};
22+
use moon_vcs::{BoxedVcs, JjAwareGit, git::Git};
2323
use moon_workspace::{WorkspaceBuilder, WorkspaceBuilderAsync, WorkspaceBuilderContext};
2424
use moon_workspace_graph::WorkspaceGraph;
2525
use proto_core::ProtoEnvironment;
@@ -272,13 +272,23 @@ impl MoonSession {
272272
if self.vcs_adapter.get().is_none() {
273273
let config = &self.workspace_config.vcs;
274274

275-
let git: BoxedVcs = Box::new(Git::load(
275+
let git = Git::load(
276276
&self.workspace_root,
277277
&config.default_branch,
278278
&config.remote_candidates,
279-
)?);
279+
)?;
280280

281-
let _ = self.vcs_adapter.set(Arc::new(git));
281+
// Inside a Jujutsu workspace (colocated or secondary), wrap the Git
282+
// backend so working-copy/revision ops route through jj — correct
283+
// even in a secondary workspace, where git sees the parent repo.
284+
// Plain-git checkouts are unaffected.
285+
let vcs: BoxedVcs = if JjAwareGit::is_jj_workspace(&git) {
286+
Box::new(JjAwareGit::new(git))
287+
} else {
288+
Box::new(git)
289+
};
290+
291+
let _ = self.vcs_adapter.set(Arc::new(vcs));
282292
}
283293

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

0 commit comments

Comments
 (0)