1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use crate::{Local, Meta, Remote};

#[serde_with::skip_serializing_none]
#[derive(serde::Serialize, serde::Deserialize, Debug, Eq, Ord, PartialEq, PartialOrd, Clone)]
#[serde(untagged)]
pub enum Repo {
    Remote(Remote),
    Local(Local),
    Meta(Meta),
}

// TODO: remove that
impl Repo {
    pub fn sort(&mut self) {
        match self {
            Self::Remote(repo) => repo.sort(),
            Self::Local(repo) => repo.sort(),
            Self::Meta(repo) => repo.sort(),
        }
    }

    pub fn equal_but_rev(&self, other: &Repo) -> bool {
        match (self, other) {
            (Self::Remote(a), Self::Remote(b)) => a.equal_but_rev(b),
            (Self::Local(a), Self::Local(b)) => a == b,
            (Self::Meta(a), Self::Meta(b)) => a == b,
            _ => false,
        }
    }
}