Run git through ssh for repositories on another machine

This commit is contained in:
2026-10-15 15:09:17 +02:00
parent 121fe1bc2f
commit 7fe5a70c69
5 changed files with 199 additions and 40 deletions
+4 -4
View File
@@ -2,7 +2,7 @@
use crate::git::git;
use serde::Serialize;
use std::path::Path;
use crate::location::Location;
#[derive(Serialize, Debug, PartialEq)]
pub struct ChangedFile {
@@ -63,13 +63,13 @@ pub fn parse_files(name_status: &str, numstat: &str) -> Vec<ChangedFile> {
files
}
pub fn load(dir: &Path, hash: &str) -> Result<CommitDetails, String> {
pub fn load(loc: &Location, hash: &str) -> Result<CommitDetails, String> {
// The hash comes from the window; refuse anything git could read as an option.
if hash.is_empty() || !hash.chars().all(|c| c.is_ascii_hexdigit()) {
return Err(format!("not a commit hash: {hash}"));
}
let info = git(
dir,
loc,
&["show", "-s", "--format=%H%x1f%an%x1f%ae%x1f%at%x1f%cn%x1f%ce%x1f%ct%x1f%P%x1f%B", hash, "--"],
)?;
let f: Vec<&str> = info.splitn(9, '\x1f').collect();
@@ -90,7 +90,7 @@ pub fn load(dir: &Path, hash: &str) -> Result<CommitDetails, String> {
let with = |flag: &'static str| {
let mut a = args.clone();
a.insert(1, flag);
git(dir, &a)
git(loc, &a)
};
let files = parse_files(&with("--name-status")?, &with("--numstat")?);