R6.6 round 1 fix: no Git says to install ElyTree; Linux keeps Mark's Git

git::own returns git::NoGit when neither the app nor ElyTree has Git;
ElyMark's Git item then reads 'needs ElyTree'. Linux AppImages stand
alone, so ElyMark keeps its Git there (packages share the AppDir).
The bundle fixture now has ElyTree's executable folder.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-15 12:21:13 -04:00
1 parent 5958e73ade
commit 8580aed6b0
8 files changed
+71 -19

No files matched your search

+24 -8
View File
@@ -32,7 +32,7 @@ pub fn locate() -> io::Result<(PathBuf, bool)> {
Some(serde_json::Value::String(path)) => return Ok((PathBuf::from(path), false)),
Some(other) => return Err(io::Error::new(io::ErrorKind::InvalidData, format!("settings: git cannot be {other}"))),
}
Ok((own(&std::env::current_exe()?), true))
Ok((own(&std::env::current_exe()?)?, true))
}
/// `git version 2.56.0…` as (2, 56); None for anything else.
@@ -64,8 +64,20 @@ pub fn system_version(path: &Path) -> io::Result<String> {
Ok(version)
}
/// No Git beside the app nor beside ElyTree.
#[derive(Debug)]
pub struct NoGit;
impl std::fmt::Display for NoGit {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str("Ely's Git is missing: ElyTree carries it")
}
}
impl std::error::Error for NoGit {}
/// The app at `exe`'s own Git, else ElyTree's, else built.
fn own(exe: &Path) -> PathBuf {
fn own(exe: &Path) -> io::Result<PathBuf> {
// ElyTree carries Git; the other apps use its copy.
let trees = crate::apps::beside(exe, AppId::Tree).into_iter().chain(crate::apps::registered(AppId::Tree));
let built = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../engines/git").join(GIT);
@@ -74,8 +86,9 @@ fn own(exe: &Path) -> PathBuf {
.into_iter()
.chain(trees.filter_map(|tree| tree.parent().map(Path::to_path_buf)))
.flat_map(|dir| [dir.join("git").join(GIT), dir.join("../Resources/git").join(GIT)])
.chain([built])
.find(|path| path.is_file())
.unwrap_or(built)
.ok_or_else(|| io::Error::new(io::ErrorKind::NotFound, NoGit))
}
/// Git at `git` in `dir`, as Ely runs it.
@@ -125,23 +138,26 @@ mod tests {
let mark = apps.path().join("ElyMark.app/Contents/MacOS");
let git = apps.path().join("ElyTree.app/Contents/Resources/git").join(GIT);
std::fs::create_dir_all(&mark).expect("ElyMark");
std::fs::create_dir_all(apps.path().join("ElyTree.app/Contents/MacOS")).expect("ElyTree");
let exe = mark.join("ely-mark");
assert!(own(&exe).ends_with(std::path::Path::new("engines/git").join(GIT)));
let built = own(&exe).expect("the built Git");
assert!(built.ends_with(std::path::Path::new("engines/git").join(GIT)));
std::fs::create_dir_all(git.parent().expect("a folder")).expect("ElyTree's Git");
std::fs::write(&git, "").expect("git");
assert_eq!(std::fs::canonicalize(own(&exe)).expect("found"), std::fs::canonicalize(&git).expect("git"));
let found = own(&exe).expect("ElyTree's Git");
assert_eq!(std::fs::canonicalize(found).expect("found"), std::fs::canonicalize(&git).expect("git"));
}
#[test]
fn windows_and_linux_installs_use_elytrees_git() {
for (mark, tree) in [("Ely Office/ElyMark", "Ely Office/ElyTree"), ("ely-office/ely-mark/bin", "ely-office/ely-tree/bin")] {
fn a_windows_install_uses_elytrees_git() {
for (mark, tree) in [("Ely Office/ElyMark", "Ely Office/ElyTree")] {
let root = tempfile::tempdir().expect("a temp dir");
let exe = root.path().join(mark).join("ely-mark");
let git = root.path().join(tree).join("git").join(GIT);
std::fs::create_dir_all(exe.parent().expect("a folder")).expect("ElyMark");
std::fs::create_dir_all(git.parent().expect("a folder")).expect("ElyTree's Git");
std::fs::write(&git, "").expect("git");
let found = std::fs::canonicalize(own(&exe)).expect("found");
let found = std::fs::canonicalize(own(&exe).expect("ElyTree's Git")).expect("found");
assert_eq!(found, std::fs::canonicalize(&git).expect("git"), "{mark}");
}
}
+4
View File
@@ -83,6 +83,8 @@ pub(super) const EN: &[(&str, &str)] = &[
("mark.git.ignored", "Git: ignored"),
("mark.git.conflicted", "Git: conflicted"),
("mark.git.unknown", "Git: unknown"),
("mark.git.none", "Git: needs ElyTree"),
("mark.git.needs", "Ely's Git comes with ElyTree. Install ElyTree from the Ely Office release to see this file's Git status."),
("mark.git.open", "Show this file's history in ElyTree"),
("mark.git.missing", "ElyTree is not installed. Install ElyTree from the Ely Office release to see this file's history."),
("mark.git.failed", "ElyTree did not open: {error}"),
@@ -184,6 +186,8 @@ pub(super) const ZH_CN: &[(&str, &str)] = &[
("mark.git.ignored", "Git:已忽略"),
("mark.git.conflicted", "Git:有冲突"),
("mark.git.unknown", "Git:未知"),
("mark.git.none", "Git:需要 ElyTree"),
("mark.git.needs", "Ely 的 Git 随 ElyTree 安装。请从 Ely Office 发行包安装 ElyTree 后查看此文件的 Git 状态。"),
("mark.git.open", "在 ElyTree 中查看此文件的历史"),
("mark.git.missing", "未安装 ElyTree。请从 Ely Office 发行包安装 ElyTree 后查看此文件的历史。"),
("mark.git.failed", "ElyTree 没能打开:{error}"),