fix: remove jj status check as it was causing divergences for other agents
This commit is contained in:
@@ -147,7 +147,6 @@
|
|||||||
"enabled": true,
|
"enabled": true,
|
||||||
"priority": 1,
|
"priority": 1,
|
||||||
"min_width": 8,
|
"min_width": 8,
|
||||||
"prefer": "auto",
|
|
||||||
"show_ahead_behind": true,
|
"show_ahead_behind": true,
|
||||||
"show_dirty": true,
|
"show_dirty": true,
|
||||||
"truncate": {
|
"truncate": {
|
||||||
|
|||||||
11
schema.json
11
schema.json
@@ -188,7 +188,6 @@
|
|||||||
"enum": [
|
"enum": [
|
||||||
"auto",
|
"auto",
|
||||||
"git",
|
"git",
|
||||||
"jj",
|
|
||||||
"none"
|
"none"
|
||||||
],
|
],
|
||||||
"description": "VCS detection mode",
|
"description": "VCS detection mode",
|
||||||
@@ -375,16 +374,6 @@
|
|||||||
"minimum": 0,
|
"minimum": 0,
|
||||||
"default": 8
|
"default": 8
|
||||||
},
|
},
|
||||||
"prefer": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"auto",
|
|
||||||
"git",
|
|
||||||
"jj"
|
|
||||||
],
|
|
||||||
"default": "auto",
|
|
||||||
"description": "VCS preference. auto detects .jj/ first, then .git/"
|
|
||||||
},
|
|
||||||
"show_ahead_behind": {
|
"show_ahead_behind": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": true
|
"default": true
|
||||||
|
|||||||
@@ -303,41 +303,14 @@ fn prefetch_shell_outs(
|
|||||||
|
|
||||||
std::thread::scope(|s| {
|
std::thread::scope(|s| {
|
||||||
let vcs_handle = if needs_vcs {
|
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 || {
|
Some(s.spawn(move || {
|
||||||
let prog = &args[0];
|
shell::exec_gated(
|
||||||
let str_args: Vec<&str> = args[1..].iter().map(|s| s.as_str()).collect();
|
shell_config,
|
||||||
shell::exec_gated(shell_config, prog, &str_args, dir.as_deref())
|
"git",
|
||||||
|
&["-C", project_dir, "status", "--porcelain=v2", "--branch"],
|
||||||
|
None,
|
||||||
|
)
|
||||||
}))
|
}))
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
@@ -483,35 +456,13 @@ fn resolve_terminal_palette(cache: &cache::Cache) -> Option<Vec<(u8, u8, u8)>> {
|
|||||||
Some(palette)
|
Some(palette)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn detect_vcs(dir: &str, config: &config::Config) -> section::VcsType {
|
fn detect_vcs(dir: &str, _config: &config::Config) -> section::VcsType {
|
||||||
let prefer = config.sections.vcs.prefer.as_str();
|
|
||||||
let path = std::path::Path::new(dir);
|
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() {
|
if path.join(".git").is_dir() {
|
||||||
section::VcsType::Git
|
section::VcsType::Git
|
||||||
} else {
|
} else {
|
||||||
section::VcsType::None
|
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
|||||||
@@ -296,7 +296,6 @@ impl Default for TruncateConfig {
|
|||||||
pub struct VcsSection {
|
pub struct VcsSection {
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub base: SectionBase,
|
pub base: SectionBase,
|
||||||
pub prefer: String,
|
|
||||||
pub show_ahead_behind: bool,
|
pub show_ahead_behind: bool,
|
||||||
pub show_dirty: bool,
|
pub show_dirty: bool,
|
||||||
pub untracked: String,
|
pub untracked: String,
|
||||||
@@ -314,7 +313,6 @@ impl Default for VcsSection {
|
|||||||
min_width: Some(8),
|
min_width: Some(8),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
prefer: "auto".into(),
|
|
||||||
show_ahead_behind: true,
|
show_ahead_behind: true,
|
||||||
show_dirty: true,
|
show_dirty: true,
|
||||||
untracked: "normal".into(),
|
untracked: "normal".into(),
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ pub type RenderFn = fn(&RenderContext) -> Option<SectionOutput>;
|
|||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum VcsType {
|
pub enum VcsType {
|
||||||
Git,
|
Git,
|
||||||
Jj,
|
|
||||||
None,
|
None,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ pub fn render(ctx: &RenderContext) -> Option<SectionOutput> {
|
|||||||
return None;
|
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 {
|
if ctx.no_shell {
|
||||||
return render_stale_cache(ctx);
|
return render_stale_cache(ctx);
|
||||||
}
|
}
|
||||||
@@ -21,11 +21,7 @@ pub fn render(ctx: &RenderContext) -> Option<SectionOutput> {
|
|||||||
let ttl = &ctx.config.sections.vcs.ttl;
|
let ttl = &ctx.config.sections.vcs.ttl;
|
||||||
let glyphs = &ctx.config.glyphs;
|
let glyphs = &ctx.config.glyphs;
|
||||||
|
|
||||||
match ctx.vcs_type {
|
render_git(ctx, dir, ttl, glyphs)
|
||||||
VcsType::Git => render_git(ctx, dir, ttl, glyphs),
|
|
||||||
VcsType::Jj => render_jj(ctx, dir, ttl, glyphs),
|
|
||||||
VcsType::None => None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Serve stale cached VCS data without running any commands.
|
/// Serve stale cached VCS data without running any commands.
|
||||||
@@ -158,53 +154,3 @@ fn render_git(
|
|||||||
|
|
||||||
Some(SectionOutput { raw, ansi })
|
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