pre_commit_sort/
repo.rs

1use crate::{Local, Meta, Remote};
2
3#[serde_with::skip_serializing_none]
4#[derive(serde::Serialize, serde::Deserialize, Debug, Eq, Ord, PartialEq, PartialOrd, Clone)]
5#[serde(untagged)]
6pub enum Repo {
7    Remote(Remote),
8    Local(Local),
9    Meta(Meta),
10}
11
12// TODO: remove that
13impl Repo {
14    pub fn sort(&mut self) {
15        match self {
16            Self::Remote(repo) => repo.sort(),
17            Self::Local(repo) => repo.sort(),
18            Self::Meta(repo) => repo.sort(),
19        }
20    }
21
22    #[must_use]
23    pub fn equal_but_rev(&self, other: &Self) -> bool {
24        match (self, other) {
25            (Self::Remote(a), Self::Remote(b)) => a.equal_but_rev(b),
26            (Self::Local(a), Self::Local(b)) => a == b,
27            (Self::Meta(a), Self::Meta(b)) => a == b,
28            _ => false,
29        }
30    }
31}