fn write_temporary_ssh_key(&self) -> anyhow::Result<tempfile::TempPath> {
        let key = match self {
            Credentials::Ssh { key } => key,
            _ => return Err(anyhow!("SSH key not available")),
        };

        let dir = if cfg!(target_os = "linux") {
            // When running on production, ensure the file is created in tmpfs and not persisted to disk
            "/dev/shm".into()
        } else {
            // For other platforms, default to std::env::tempdir()
            std::env::temp_dir()
        };

        let mut temp_key_file = tempfile::Builder::new()
            .tempfile_in(dir)
            .context("Failed to create temporary file")?;

        temp_key_file
            .write_all(key.as_bytes())
            .context("Failed to write SSH key to temporary file")?;

        Ok(temp_key_file.into_temp_path())
    }
/// Write the SSH key to a temporary file and return the path. The file is
/// deleted once the returned path is dropped.
///
/// This function can be used when running `git push` instead of using the
/// `git2` crate for pushing commits to remote git servers.
///
/// Note: On Linux this function creates the temporary file in `/dev/shm` to
/// avoid writing it to disk.
///
/// # Errors
///
/// - If non-SSH credentials are use, `Err` is returned.
/// - If creation of the temporary file fails, `Err` is returned.
///
Write the SSH key to a temporary file and return the path. The file is
deleted once the returned path is dropped.

This function can be used when running `git push` instead of using the
`git2` crate for pushing commits to remote git servers.

On Linux this function creates the temporary file in `/dev/shm` to
avoid writing it to disk.
Write the SSH key to a temporary file and return the path . The file is deleted once the returned path is dropped . This function can be used when running ` git push ` instead of using the ` git2 ` crate for pushing commits to remote git servers . On Linux this function creates the temporary file in ` / dev / shm ` to avoid writing it to disk .
fn write_temporary_ssh_key(&self) -> anyhow::Result<tempfile::TempPath> {
        let key = match self {
            Credentials::Ssh { key } => key,
            _ => return Err(anyhow!("SSH key not available")),
        };
        let dir = if cfg!(target_os = "linux") {
            // When running on production, ensure the file is created in tmpfs and not persisted to disk
            "/dev/shm".into()
        } else {
            // For other platforms, default to std::env::tempdir()
            std::env::temp_dir()
        };
        let mut temp_key_file = tempfile::Builder::new()
            .tempfile_in(dir)
            .context("Failed to create temporary file")?;
        temp_key_file
            .write_all(key.as_bytes())
            .context("Failed to write SSH key to temporary file")?;
        Ok(temp_key_file.into_temp_path())
    }
fn write_temporary_ssh_key ( & self ) -> anyhow :: Result < tempfile :: TempPath > { let key = match self { Credentials :: Ssh { key } => key , _ => return Err ( anyhow ! ( " " ) ) , } ; let dir = if cfg ! ( target_os " " ) { // When running on production, ensure the file is created in tmpfs and not persisted to disk " " . into ( ) } else { // For other platforms, default to std::env::tempdir() std :: env :: temp_dir ( ) } ; let mut temp_key_file = tempfile :: Builder :: new ( ) . tempfile_in ( dir ) . context ( " " ) ? ; temp_key_file . write_all ( key . as_bytes ( ) ) . context ( " " ) ? ; Ok ( temp_key_file . into_temp_path ( ) ) }
Write the SSH key to a temporary file and return the path.
Write the SSH key to a temporary file and return the path .
&self
errors
If non-SSH credentials are use, `Err` is returned.
If creation of the temporary file fails, `Err` is returned.
If non - SSH credentials are use ` Err ` is returned . If creation of the temporary file fails ` Err ` is returned .