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:
1 parent
5958e73ade
commit
8580aed6b0
8 files changed
+71
-19
No files matched your search
@@ -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}");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user