Proper parsing of URLs

[?]
Jan 13, 2021, 2:37 PM
GYXIF25T2BCTCWCQI5DQOF3F4HBWDJUDJUMZ2WLHVBIOYATJTFAQC

Dependencies

  • [2] JRENVH5D Reqwest 0.11
  • [3] 5XMUEZMZ pijul-clone: avoid panics on parsing remote URLs
  • [4] VBMXB443 Retrying if the HTTP connection drops while reading the body
  • [5] 367UBQ6K Forwarding SSH stderr, and progress bar for push
  • [6] CCLLB7OI Upgrading to Sanakirja 0.15 + version bump
  • [7] SZWBLWZ4 Reading ~/.ssh/config
  • [8] TPEH2XNB 1.0.0-alpha.28, with Tokio 1.0
  • [9] Q45QHPO4 Feedback on network stuff
  • [10] 76PCXGML Pushing to, and pulling from the local repository
  • [11] K6GWUOD5 Styling progress bars
  • [12] IQ4FCHPZ HTTP connections: pooling + retry on error
  • [13] FBXYP7QM Forgot to add remote::http
  • [14] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [15] MU5GSJAW Partial push and pull (WARNING: breaks the existing protocol)
  • [16] KI2AFWOS Fixing a panic in pull
  • [*] LYTVEPH3 Avoid cloning into an existing path
  • [*] 2K7JLB4Z No pager on Windows
  • [*] BT2ZHPY4 Version bumps

Change contents

  • replacement in pijul/src/remote/mod.rs at line 59
    [4.53500][4.53500:53622](),[4.53622][4.243:285](),[4.285][4.53657:53907](),[4.53657][4.53657:53907](),[4.53907][4.286:341](),[4.341][4.2649:2706](),[4.2706][4.54008:54130](),[4.394][4.54008:54130](),[4.54008][4.54008:54130]()
    if name.starts_with("http://") || name.starts_with("https://") {
    debug!("unknown_remote, http = {:?}", name);
    return Ok(RemoteRepo::Http(Http {
    url: name.to_string(),
    channel: channel.to_string(),
    client: reqwest::ClientBuilder::new()
    .danger_accept_invalid_certs(no_cert_check)
    .build()?,
    name: name.to_string(),
    }));
    }
    if name.starts_with("ssh://") {
    return if let Some(mut ssh) = ssh_remote(name) {
    debug!("unknown_remote, ssh = {:?}", ssh);
    Ok(RemoteRepo::Ssh(ssh.connect(name, channel).await?))
    [4.53500]
    [4.54130]
    if let Ok(url) = url::Url::parse(name) {
    let scheme = url.scheme();
    if scheme == "http" || scheme == "https" {
    debug!("unknown_remote, http = {:?}", name);
    return Ok(RemoteRepo::Http(Http {
    url,
    channel: channel.to_string(),
    client: reqwest::ClientBuilder::new()
    .danger_accept_invalid_certs(no_cert_check)
    .build()?,
    name: name.to_string(),
    }));
    } else if scheme == "ssh" {
    return if let Some(mut ssh) = ssh_remote(name) {
    debug!("unknown_remote, ssh = {:?}", ssh);
    Ok(RemoteRepo::Ssh(ssh.connect(name, channel).await?))
    } else {
    bail!("Remote not found: {:?}", name)
    };
  • replacement in pijul/src/remote/mod.rs at line 79
    [4.54147][4.8246:8296](),[4.8296][4.395:406](),[4.54266][4.395:406]()
    bail!("Remote not found: {:?}", name)
    };
    [4.54147]
    [4.406]
    bail!("Remote scheme not supported: {:?}", scheme)
    }
  • replacement in pijul/src/remote/mod.rs at line 146
    [4.56131][3.474:599](),[3.599][4.56195:56271](),[4.56195][4.56195:56271](),[4.56271][3.600:647](),[3.647][4.56314:56339](),[4.56314][4.56314:56339](),[4.56339][3.648:706]()
    let url =
    reqwest::Url::parse(&h.url).context("failed to parse remote repository URL")?;
    if let Some(name) = libpijul::path::file_name(url.path()) {
    Ok(Some(name.to_string()))
    } else {
    Ok(url.host().map(|h| h.to_string()))
    [4.56131]
    [4.56393]
    if let Some(name) = libpijul::path::file_name(h.url.path()) {
    if !name.trim().is_empty() {
    return Ok(Some(name.trim().to_string()));
    }
  • edit in pijul/src/remote/mod.rs at line 151
    [4.56411]
    [4.56411]
    Ok(h.url.host().map(|h| h.to_string()))
  • replacement in pijul/src/remote/http.rs at line 12
    [4.106][4.106:127]()
    pub url: String,
    [4.106]
    [4.127]
    pub url: url::Url,
  • replacement in pijul/src/remote/http.rs at line 20
    [4.84][4.84:101]()
    url: String,
    [4.84]
    [4.101]
    url: url::Url,
  • replacement in pijul/src/remote/http.rs at line 142
    [4.1226][4.1226:1289]()
    let url = self.url.clone() + "/" + super::DOT_DIR;
    [4.1226]
    [4.1289]
    let url = {
    let mut p = self.url.path().to_string();
    if !p.ends_with("/") {
    p.push('/')
    }
    p.push_str(super::DOT_DIR);
    let mut u = self.url.clone();
    u.set_path(&p);
    u
    };
  • replacement in pijul/src/remote/http.rs at line 162
    [4.1663][4.1663:1691]()
    .post(&url)
    [4.1663]
    [4.1691]
    .post(url)
  • replacement in pijul/src/remote/http.rs at line 184
    [4.5326][4.5326:5385]()
    let url = self.url.clone() + "/" + super::DOT_DIR;
    [4.5326]
    [4.5385]
    let url = {
    let mut p = self.url.path().to_string();
    if !p.ends_with("/") {
    p.push('/')
    }
    p.push_str(super::DOT_DIR);
    let mut u = self.url.clone();
    u.set_path(&p);
    u
    };
  • replacement in pijul/src/remote/http.rs at line 199
    [4.5584][2.138:207]()
    let res = self.client.get(&url).query(&query).send().await?;
    [4.5584]
    [4.5653]
    let res = self.client.get(url).query(&query).send().await?;
  • replacement in pijul/src/remote/http.rs at line 267
    [4.1531][4.1531:1668]()
    let url = self.url.clone() + "/" + super::DOT_DIR;
    let res = self.client.get(&url).query(&[("channel", &self.channel)]);
    [4.1531]
    [4.1668]
    let url = {
    let mut p = self.url.path().to_string();
    if !p.ends_with("/") {
    p.push('/')
    }
    p.push_str(super::DOT_DIR);
    let mut u = self.url.clone();
    u.set_path(&p);
    u
    };
    let res = self.client.get(url).query(&[("channel", &self.channel)]);
  • edit in pijul/Cargo.toml at line 81
    [18.472]
    [19.309]
    url = "2.2"
  • edit in Cargo.lock at line 1324
    [4.1064526]
    [20.314]
    "url",