Allow remotes to have a different push and pull address

pmeunier
Aug 4, 2021, 8:32 AM
ZSFJT4SFIAS7WBODRZOFKKG4SVYBC5PC6XY75WYN7CCQ3SMV7IUQC

Dependencies

  • [2] A3RM526Y Integrating identity malleability
  • [3] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [4] KWAGWB73 Adding extra dependencies from the config file
  • [5] SEWGHUHQ .pijul/config: simplify remotes and hooks
  • [6] 5OGOE4VW Store the current channel in the pristine
  • [7] EEBKW7VT Keys and identities
  • [8] 76PCXGML Pushing to, and pulling from the local repository
  • [9] IUGP6ZGB Add support for ~/.config/pijul even on macos
  • [10] CCLLB7OI Upgrading to Sanakirja 0.15 + version bump
  • [*] L4JXJHWX pijul/*: reorganize imports and remove extern crate
  • [*] 5BB266P6 Optional colours in the global config file
  • [*] 2D7P2VKJ Change completions (where the whole progress bar story started)

Change contents

  • edit in pijul/src/remote/mod.rs at line 15
    [12.457]
    [12.457]
    use crate::config::*;
  • edit in pijul/src/remote/mod.rs at line 43
    [3.53074]
    [3.53074]
    direction: Direction,
  • replacement in pijul/src/remote/mod.rs at line 48
    [3.53208][2.6010:6095]()
    unknown_remote(self_path, name, channel, no_cert_check, with_path).await
    [3.53208]
    [3.53271]
    unknown_remote(
    self_path,
    name.with_dir(direction),
    channel,
    no_cert_check,
    with_path,
    )
    .await
  • replacement in pijul/src/config.rs at line 97
    [3.90973][3.90973:91023]()
    #[derive(Debug, Serialize, Deserialize, Default)]
    [3.90973]
    [3.91023]
    #[derive(Debug, Deserialize, Default)]
  • replacement in pijul/src/config.rs at line 103
    [3.22][3.91124:91166](),[3.91124][3.91124:91166]()
    pub remotes: HashMap<String, String>,
    [3.22]
    [3.23]
    pub remotes: HashMap<String, RemoteName>,
  • edit in pijul/src/config.rs at line 108
    [13.315]
    [3.91196]
    }
    #[derive(Debug)]
    pub enum RemoteName {
    Name(String),
    Split(SplitRemote),
    }
    #[derive(Clone, Copy, Debug)]
    pub enum Direction {
    Push,
    Pull,
    }
    impl RemoteName {
    pub fn with_dir(&self, d: Direction) -> &str {
    match (self, d) {
    (RemoteName::Name(ref s), _) => s,
    (RemoteName::Split(ref s), Direction::Pull) => &s.pull,
    (RemoteName::Split(ref s), Direction::Push) => &s.push,
    }
    }
    }
    use serde::de::{self, MapAccess, Visitor};
    use serde::de::{Deserialize, Deserializer};
    use std::fmt;
    use std::marker::PhantomData;
    impl<'de> Deserialize<'de> for RemoteName {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
    D: Deserializer<'de>,
    {
    struct StringOrStruct(PhantomData<fn() -> RemoteName>);
    impl<'de> Visitor<'de> for StringOrStruct {
    type Value = RemoteName;
    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
    formatter.write_str("string or map")
    }
    fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
    where
    E: de::Error,
    {
    Ok(RemoteName::Name(value.to_string()))
    }
    fn visit_map<M>(self, map: M) -> Result<Self::Value, M::Error>
    where
    M: MapAccess<'de>,
    {
    // `MapAccessDeserializer` is a wrapper that turns a `MapAccess`
    // into a `Deserializer`, allowing it to be used as the input to T's
    // `Deserialize` implementation. T then deserializes itself using
    // the entries from the map visitor.
    Ok(RemoteName::Split(Deserialize::deserialize(
    de::value::MapAccessDeserializer::new(map),
    )?))
    }
    }
    deserializer.deserialize_any(StringOrStruct(PhantomData))
    }
  • edit in pijul/src/config.rs at line 174
    [3.91199]
    [3.91199]
    #[derive(Debug, Deserialize)]
    pub struct SplitRemote {
    pub pull: String,
    pub push: String,
    }
  • edit in pijul/src/commands/pushpull.rs at line 15
    [12.1761]
    [14.4774]
    use crate::config::Direction;
  • edit in pijul/src/commands/pushpull.rs at line 212
    [3.4447]
    [3.4447]
    Direction::Push,
  • edit in pijul/src/commands/pushpull.rs at line 376
    [3.6071]
    [3.6071]
    Direction::Pull,
  • replacement in pijul/src/commands/key.rs at line 95
    [2.23023][2.23023:23116]()
    .remote(None, &remote, crate::DEFAULT_CHANNEL, no_cert_check, false)
    [2.23023]
    [2.23116]
    .remote(
    None,
    &remote,
    crate::DEFAULT_CHANNEL,
    Direction::Pull,
    no_cert_check,
    false,
    )