Fixing a counter-intuitive error when a local repo does not exist

pmeunier
Dec 6, 2021, 12:20 PM
CXSCA5HNK3BSSUMZ2SZ5XNKSSHC2IFHPC35SMO5WMWVJBYEFSJTQC

Dependencies

  • [2] IVLLXQ5Z Improved push/pull reporting
  • [3] SZWBLWZ4 Reading ~/.ssh/config
  • [4] FE5ES6Q4 Stop pushing/pulling if the remote returns an error
  • [5] ZSFJT4SF Allow remotes to have a different push and pull address
  • [6] YN63NUZO Sanakirja 1.0
  • [7] JACZYXK4 Fixing a bug in unrecord
  • [8] IRTYN5FF Remove duplicated line in remote/mod.rs
  • [9] CCLLB7OI Upgrading to Sanakirja 0.15 + version bump
  • [10] A3RM526Y Integrating identity malleability
  • [11] UDHP4ZVB Fixing SSH asynchronicity issues
  • [12] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [13] GYXIF25T Proper parsing of URLs
  • [14] EEBKW7VT Keys and identities
  • [15] KVCXCDRM Fixing warnings with Rust 1.57 + cleanup
  • [16] 76PCXGML Pushing to, and pulling from the local repository

Change contents

  • replacement in pijul/src/remote/ssh.rs at line 88
    [3.27320][3.531:626]()
    pub async fn connect(&mut self, name: &str, channel: &str) -> Result<Ssh, anyhow::Error> {
    [3.27320]
    [3.27411]
    pub async fn connect(
    &mut self,
    name: &str,
    channel: &str,
    ) -> Result<Option<Ssh>, anyhow::Error> {
  • replacement in pijul/src/remote/ssh.rs at line 106
    [3.27694][3.677:727]()
    let stream = self.config.stream().await?;
    [3.27694]
    [3.27694]
    let stream = match self.config.stream().await {
    Ok(stream) => stream,
    Err(e) => {
    info!("remote connect error: {:?}", e);
    return Ok(None);
    }
    };
  • replacement in pijul/src/remote/ssh.rs at line 137
    [3.28569][3.28569:28586]()
    Ok(Ssh {
    [3.28569]
    [3.28586]
    Ok(Some(Ssh {
  • replacement in pijul/src/remote/ssh.rs at line 147
    [3.178][3.28790:28801](),[3.186][3.28790:28801](),[3.28790][3.28790:28801]()
    })
    [3.178]
    [3.28801]
    }))
  • replacement in pijul/src/remote/mod.rs at line 82
    [3.543][3.6204:6276]()
    return if let Some(mut ssh) = ssh_remote(name, with_path) {
    [3.543]
    [3.604]
    if let Some(mut ssh) = ssh_remote(name, with_path) {
  • replacement in pijul/src/remote/mod.rs at line 84
    [3.663][3.663:824]()
    Ok(RemoteRepo::Ssh(ssh.connect(name, channel).await?))
    } else {
    bail!("Remote not found: {:?}", name)
    };
    [3.663]
    [3.54130]
    if let Some(c) = ssh.connect(name, channel).await? {
    return Ok(RemoteRepo::Ssh(c));
    }
    }
    bail!("Remote not found: {:?}", name)
  • replacement in pijul/src/remote/mod.rs at line 106
    [3.54479][3.7031:7129](),[3.7129][3.54566:54603](),[3.54566][3.54566:54603](),[3.54603][3.724:772](),[3.772][3.0:53](),[3.53][3.54644:54719](),[3.772][3.54644:54719](),[3.54644][3.54644:54719](),[3.54719][3.10385:10431](),[3.54798][3.54798:54838](),[3.54838][3.773:790]()
    if let Ok(pristine) = libpijul::pristine::sanakirja::Pristine::new(&dot_dir.join("db")) {
    debug!("pristine done");
    return Ok(RemoteRepo::Local(Local {
    root: Path::new(name).to_path_buf(),
    channel: channel.to_string(),
    changes_dir,
    pristine: Arc::new(pristine),
    name: name.to_string(),
    }));
    [3.54479]
    [3.55165]
    match libpijul::pristine::sanakirja::Pristine::new(&dot_dir.join("db")) {
    Ok(pristine) => {
    debug!("pristine done");
    return Ok(RemoteRepo::Local(Local {
    root: Path::new(name).to_path_buf(),
    channel: channel.to_string(),
    changes_dir,
    pristine: Arc::new(pristine),
    name: name.to_string(),
    }));
    }
    Err(libpijul::pristine::sanakirja::SanakirjaError::Sanakirja(
    sanakirja::Error::IO(e),
    )) if e.kind() == std::io::ErrorKind::NotFound => {
    debug!("repo not found")
    }
    Err(e) => return Err(e.into()),
  • replacement in pijul/src/remote/mod.rs at line 127
    [3.884][3.884:960](),[3.960][3.8297:8343]()
    Ok(RemoteRepo::Ssh(ssh.connect(name, channel).await?))
    } else {
    bail!("Remote not found: {:?}", name)
    [3.884]
    [2.210]
    if let Some(c) = ssh.connect(name, channel).await? {
    return Ok(RemoteRepo::Ssh(c));
    }
  • edit in pijul/src/remote/mod.rs at line 131
    [2.216]
    [2.216]
    bail!("Remote not found: {:?}", name)
  • replacement in pijul/src/commands/key.rs at line 110
    [3.23404][3.23404:23476]()
    ssh.connect(&remote, crate::DEFAULT_CHANNEL).await?
    [3.23404]
    [3.23476]
    if let Some(c) = ssh.connect(&remote, crate::DEFAULT_CHANNEL).await? {
    c
    } else {
    bail!("No such remote: {}", remote)
    }