summaryrefslogtreecommitdiff
path: root/server/common
diff options
context:
space:
mode:
Diffstat (limited to 'server/common')
-rw-r--r--server/common/Cargo.toml1
-rw-r--r--server/common/src/git.rs17
-rw-r--r--server/common/src/tests.rs2
3 files changed, 20 insertions, 0 deletions
diff --git a/server/common/Cargo.toml b/server/common/Cargo.toml
index aa358b2..fdabffa 100644
--- a/server/common/Cargo.toml
+++ b/server/common/Cargo.toml
@@ -5,6 +5,7 @@ edition = "2021"
[dependencies]
futures.workspace = true
+log.workspace = true
pathdiff = "0.2.3"
serde.workspace = true
tokio = { workspace = true, features = ["fs", "macros", "process", "rt", "sync"] }
diff --git a/server/common/src/git.rs b/server/common/src/git.rs
index ac0bdb3..6678db7 100644
--- a/server/common/src/git.rs
+++ b/server/common/src/git.rs
@@ -49,6 +49,7 @@ pub struct Repository {
project_id: Option<String>,
socket: Option<PathBuf>,
githook: Option<PathBuf>,
+ ssh_config: Option<PathBuf>,
// Lock for any repo task, 90% of all tasks are readers but there are some writers
// where nothing else may be done.
@@ -138,6 +139,15 @@ impl RepoData {
self.config_set(repo, "eyeballs.socket", relative.to_str().unwrap())
.await?;
}
+ if let Some(ssh_config) = repo.ssh_config() {
+ let relative = diff_paths(ssh_config, repo.path()).unwrap();
+ self.config_set(
+ repo,
+ "core.sshcommand",
+ format!("ssh -F {}", relative.to_str().unwrap()).as_str(),
+ )
+ .await?;
+ }
// Handled by pre-receive hook, allow fast forwards for reviews that expect it.
self.config_set(repo, "receive.denyNonFastForwards", "false")
@@ -454,10 +464,12 @@ impl Repository {
remote: Option<impl Into<String>>,
project_id: Option<impl Into<String>>,
githook: Option<impl Into<PathBuf>>,
+ ssh_config: Option<impl Into<PathBuf>>,
) -> Self {
let path = path.into();
let project_id = project_id.map(|x| x.into());
let githook = githook.map(|x| x.into());
+ let ssh_config = ssh_config.map(|x| x.into());
let socket: Option<PathBuf>;
if let Some(project_id) = &project_id {
socket = Some(
@@ -475,6 +487,7 @@ impl Repository {
path,
socket,
githook,
+ ssh_config,
bare,
lock: RwLock::new(RepoData::new()),
}
@@ -500,6 +513,10 @@ impl Repository {
self.githook.as_deref()
}
+ pub fn ssh_config(&self) -> Option<&Path> {
+ self.ssh_config.as_deref()
+ }
+
pub fn is_bare(&self) -> bool {
self.bare
}
diff --git a/server/common/src/tests.rs b/server/common/src/tests.rs
index 41f44fe..5a02119 100644
--- a/server/common/src/tests.rs
+++ b/server/common/src/tests.rs
@@ -59,6 +59,7 @@ async fn git_setup(bare: bool) -> git::Repository {
None::<String>,
None::<String>,
None::<PathBuf>,
+ None::<PathBuf>,
);
assert_eq!(repo.remote(), None);
assert_eq!(repo.project_id(), None);
@@ -212,6 +213,7 @@ async fn git_fetch(bare: bool) -> git::Repository {
Some(remote.as_str()),
None::<String>,
None::<PathBuf>,
+ None::<PathBuf>,
);
assert_eq!(repo.remote(), Some(remote.as_str()));
repo.setup().await.unwrap();