63 lines · 1.9 KB · Rust
RawDownload
use crate::{    config,    config::tree::{keys, Key, Section, Ssh},}; impl Ssh {    /// The `ssh.variant` key    pub const VARIANT: Variant = Variant::new_with_validate("variant", &config::Tree::SSH, validate::Variant)        .with_environment_override("GIT_SSH_VARIANT")        .with_deviation("We error if a variant is chosen that we don't know, as opposed to defaulting to 'ssh'");} /// The `ssh.variant` key.pub type Variant = keys::Any<validate::Variant>; #[cfg(feature = "blocking-network-client")]mod variant {    use std::borrow::Cow;     use crate::{bstr::BStr, config, config::tree::ssh::Variant};     impl Variant {        pub fn try_into_variant(            &'static self,            value: Cow<'_, BStr>,        ) -> Result<Option<git_protocol::transport::client::ssh::ProgramKind>, config::key::GenericErrorWithValue>        {            use git_protocol::transport::client::ssh::ProgramKind;            Ok(Some(match value.as_ref().as_ref() {                b"auto" => return Ok(None),                b"ssh" => ProgramKind::Ssh,                b"plink" => ProgramKind::Plink,                b"putty" => ProgramKind::Putty,                b"tortoiseplink" => ProgramKind::TortoisePlink,                b"simple" => ProgramKind::Simple,                _ => return Err(config::key::GenericErrorWithValue::from_value(self, value.into_owned())),            }))        }    }} impl Section for Ssh {    fn name(&self) -> &str {        "ssh"    }     fn keys(&self) -> &[&dyn Key] {        &[&Self::VARIANT]    }} mod validate {    use crate::{bstr::BStr, config::tree::keys};     pub struct Variant;    impl keys::Validate for Variant {        fn validate(&self, _value: &BStr) -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {            #[cfg(feature = "blocking-network-client")]            super::Ssh::VARIANT.try_into_variant(_value.into())?;            Ok(())        }    }}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t