fix: remove jj status check as it was causing divergences for other agents
This commit is contained in:
@@ -147,7 +147,6 @@
|
||||
"enabled": true,
|
||||
"priority": 1,
|
||||
"min_width": 8,
|
||||
"prefer": "auto",
|
||||
"show_ahead_behind": true,
|
||||
"show_dirty": true,
|
||||
"truncate": {
|
||||
|
||||
11
schema.json
11
schema.json
@@ -188,7 +188,6 @@
|
||||
"enum": [
|
||||
"auto",
|
||||
"git",
|
||||
"jj",
|
||||
"none"
|
||||
],
|
||||
"description": "VCS detection mode",
|
||||
@@ -375,16 +374,6 @@
|
||||
"minimum": 0,
|
||||
"default": 8
|
||||
},
|
||||
"prefer": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"auto",
|
||||
"git",
|
||||
"jj"
|
||||
],
|
||||
"default": "auto",
|
||||
"description": "VCS preference. auto detects .jj/ first, then .git/"
|
||||
},
|
||||
"show_ahead_behind": {
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
|
||||
@@ -303,41 +303,14 @@ fn prefetch_shell_outs(
|
||||
|
||||
std::thread::scope(|s| {
|
||||
let vcs_handle = if needs_vcs {
|
||||
let args: Vec<String> = match vcs_type {
|
||||
section::VcsType::Git => vec![
|
||||
"git".into(),
|
||||
"-C".into(),
|
||||
project_dir.into(),
|
||||
"status".into(),
|
||||
"--porcelain=v2".into(),
|
||||
"--branch".into(),
|
||||
],
|
||||
section::VcsType::Jj => vec![
|
||||
"jj".into(),
|
||||
"log".into(),
|
||||
"-r".into(),
|
||||
"@".into(),
|
||||
"--no-graph".into(),
|
||||
"-T".into(),
|
||||
"if(bookmarks, bookmarks.join(\",\"), change_id.shortest(8))".into(),
|
||||
"--color=never".into(),
|
||||
],
|
||||
section::VcsType::None => vec![],
|
||||
};
|
||||
if args.is_empty() {
|
||||
None
|
||||
} else {
|
||||
let dir = if vcs_type == section::VcsType::Jj {
|
||||
Some(project_dir.to_string())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
Some(s.spawn(move || {
|
||||
let prog = &args[0];
|
||||
let str_args: Vec<&str> = args[1..].iter().map(|s| s.as_str()).collect();
|
||||
shell::exec_gated(shell_config, prog, &str_args, dir.as_deref())
|
||||
}))
|
||||
}
|
||||
Some(s.spawn(move || {
|
||||
shell::exec_gated(
|
||||
shell_config,
|
||||
"git",
|
||||
&["-C", project_dir, "status", "--porcelain=v2", "--branch"],
|
||||
None,
|
||||
)
|
||||
}))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
@@ -483,34 +456,12 @@ fn resolve_terminal_palette(cache: &cache::Cache) -> Option<Vec<(u8, u8, u8)>> {
|
||||
Some(palette)
|
||||
}
|
||||
|
||||
fn detect_vcs(dir: &str, config: &config::Config) -> section::VcsType {
|
||||
let prefer = config.sections.vcs.prefer.as_str();
|
||||
fn detect_vcs(dir: &str, _config: &config::Config) -> section::VcsType {
|
||||
let path = std::path::Path::new(dir);
|
||||
|
||||
match prefer {
|
||||
"jj" => {
|
||||
if path.join(".jj").is_dir() {
|
||||
section::VcsType::Jj
|
||||
} else {
|
||||
section::VcsType::None
|
||||
}
|
||||
}
|
||||
"git" => {
|
||||
if path.join(".git").is_dir() {
|
||||
section::VcsType::Git
|
||||
} else {
|
||||
section::VcsType::None
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
if path.join(".jj").is_dir() {
|
||||
section::VcsType::Jj
|
||||
} else if path.join(".git").is_dir() {
|
||||
section::VcsType::Git
|
||||
} else {
|
||||
section::VcsType::None
|
||||
}
|
||||
}
|
||||
if path.join(".git").is_dir() {
|
||||
section::VcsType::Git
|
||||
} else {
|
||||
section::VcsType::None
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -296,7 +296,6 @@ impl Default for TruncateConfig {
|
||||
pub struct VcsSection {
|
||||
#[serde(flatten)]
|
||||
pub base: SectionBase,
|
||||
pub prefer: String,
|
||||
pub show_ahead_behind: bool,
|
||||
pub show_dirty: bool,
|
||||
pub untracked: String,
|
||||
@@ -314,7 +313,6 @@ impl Default for VcsSection {
|
||||
min_width: Some(8),
|
||||
..Default::default()
|
||||
},
|
||||
prefer: "auto".into(),
|
||||
show_ahead_behind: true,
|
||||
show_dirty: true,
|
||||
untracked: "normal".into(),
|
||||
|
||||
@@ -52,7 +52,6 @@ pub type RenderFn = fn(&RenderContext) -> Option<SectionOutput>;
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum VcsType {
|
||||
Git,
|
||||
Jj,
|
||||
None,
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ pub fn render(ctx: &RenderContext) -> Option<SectionOutput> {
|
||||
return None;
|
||||
}
|
||||
|
||||
// --no-shell: serve stale cache only, skip all git/jj commands
|
||||
// --no-shell: serve stale cache only, skip all git commands
|
||||
if ctx.no_shell {
|
||||
return render_stale_cache(ctx);
|
||||
}
|
||||
@@ -21,11 +21,7 @@ pub fn render(ctx: &RenderContext) -> Option<SectionOutput> {
|
||||
let ttl = &ctx.config.sections.vcs.ttl;
|
||||
let glyphs = &ctx.config.glyphs;
|
||||
|
||||
match ctx.vcs_type {
|
||||
VcsType::Git => render_git(ctx, dir, ttl, glyphs),
|
||||
VcsType::Jj => render_jj(ctx, dir, ttl, glyphs),
|
||||
VcsType::None => None,
|
||||
}
|
||||
render_git(ctx, dir, ttl, glyphs)
|
||||
}
|
||||
|
||||
/// Serve stale cached VCS data without running any commands.
|
||||
@@ -158,53 +154,3 @@ fn render_git(
|
||||
|
||||
Some(SectionOutput { raw, ansi })
|
||||
}
|
||||
|
||||
fn render_jj(
|
||||
ctx: &RenderContext,
|
||||
dir: &str,
|
||||
ttl: &crate::config::VcsTtl,
|
||||
glyphs: &crate::config::GlyphConfig,
|
||||
) -> Option<SectionOutput> {
|
||||
use std::time::Duration;
|
||||
|
||||
let branch_ttl = Duration::from_secs(ttl.branch);
|
||||
|
||||
let branch = ctx.cache.get("vcs_branch", branch_ttl).or_else(|| {
|
||||
// Use prefetched result if available, otherwise exec
|
||||
let out = ctx.shell_results.get("vcs").cloned().unwrap_or_else(|| {
|
||||
shell::exec_gated(
|
||||
ctx.shell_config,
|
||||
"jj",
|
||||
&[
|
||||
"log",
|
||||
"-r",
|
||||
"@",
|
||||
"--no-graph",
|
||||
"-T",
|
||||
"if(bookmarks, bookmarks.join(\",\"), change_id.shortest(8))",
|
||||
"--color=never",
|
||||
],
|
||||
Some(dir),
|
||||
)
|
||||
})?;
|
||||
ctx.cache.set("vcs_branch", &out);
|
||||
Some(out)
|
||||
})?;
|
||||
|
||||
let trunc = &ctx.config.sections.vcs.truncate;
|
||||
let branch = if trunc.enabled && trunc.max > 0 {
|
||||
crate::format::truncate(&branch, trunc.max, &trunc.style)
|
||||
} else {
|
||||
branch
|
||||
};
|
||||
|
||||
let branch_glyph = glyph::glyph("branch", glyphs);
|
||||
let raw = format!("{branch_glyph}{branch}");
|
||||
let ansi = if ctx.color_enabled {
|
||||
format!("{}{branch_glyph}{branch}{}", color::GREEN, color::RESET)
|
||||
} else {
|
||||
raw.clone()
|
||||
};
|
||||
|
||||
Some(SectionOutput { raw, ansi })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user