Keep the window responsive and ssh connections safe

Commands that run git now run away from the thread that draws the
window, so a slow server no longer freezes it. ssh now notices a server
that stopped answering in about 10 seconds. The sockets for shared
connections go in the runtime folder, or else in a private gites folder
in the cache folder, never in /tmp; without either, connections are not
shared. A path that is exactly ~ now means the home folder on the
server.

Tests cover commit details through ssh, the message for a failed
connection, and a ~/ path end to end. The stand-in ssh is now set per
test, so a test can give it its own home folder.
This commit is contained in:
2026-10-15 15:26:16 +02:00
parent 5ef5c1ba94
commit bf6ae3e2bb
5 changed files with 181 additions and 21 deletions
+34 -1
View File
@@ -16,7 +16,7 @@ pub struct ChangedFile {
pub deleted: Option<u32>,
}
#[derive(Serialize, Debug)]
#[derive(Serialize, Debug, PartialEq)]
pub struct CommitDetails {
hash: String,
author: String,
@@ -153,4 +153,37 @@ mod tests {
fn parses_an_empty_diff() {
assert_eq!(parse_files("", ""), vec![]);
}
#[test]
fn shows_the_same_details_through_ssh() {
use std::process::Command;
let dir = std::env::temp_dir().join(format!("gites-details-ssh-{}", std::process::id()));
let _ = std::fs::remove_dir_all(&dir);
std::fs::create_dir_all(&dir).unwrap();
let run = |args: &[&str]| {
let out = Command::new("git")
.arg("-C")
.arg(&dir)
.args(["-c", "user.name=Test", "-c", "user.email=test@example.com", "-c", "commit.gpgsign=false"])
.args(args)
.output()
.unwrap();
assert!(out.status.success(), "git {args:?}: {}", String::from_utf8_lossy(&out.stderr));
String::from_utf8_lossy(&out.stdout).trim().to_string()
};
run(&["init", "-q", "-b", "main"]);
std::fs::write(dir.join("it's $a; b.txt"), "one\ntwo\n").unwrap();
run(&["add", "-A"]);
run(&["commit", "-q", "-m", "first"]);
std::fs::write(dir.join("it's $a; b.txt"), "one\nthree\n").unwrap();
run(&["commit", "-q", "-am", "second\n\nwith a body"]);
let hash = run(&["rev-parse", "HEAD"]);
crate::test_ssh::fake_ssh();
let remote = Location::Ssh { target: "myserver".into(), path: dir.to_string_lossy().into_owned() };
let local = load(&Location::Local(dir.clone()), &hash).unwrap();
let through_ssh = load(&remote, &hash).unwrap();
assert_eq!(local.files, vec![file("M", "it's $a; b.txt", None, Some(1), Some(1))]);
assert_eq!(local, through_ssh);
let _ = std::fs::remove_dir_all(&dir);
}
}