2024-07-25 09:02:43 +01:00
|
|
|
use crate::config::{RepoBranches, RepoConfigSource};
|
2024-05-11 19:46:20 +01:00
|
|
|
|
|
|
|
/// Mapped from `.git-next.toml` file in target repo
|
|
|
|
/// Is also derived from the optional parameters in `git-next-server.toml` at
|
|
|
|
/// `forge.{forge}.repos.{repo}.(main|next|dev)`
|
2024-05-15 07:55:05 +01:00
|
|
|
#[derive(
|
2024-06-19 07:02:18 +01:00
|
|
|
Clone,
|
|
|
|
Hash,
|
|
|
|
Debug,
|
|
|
|
PartialEq,
|
|
|
|
Eq,
|
|
|
|
PartialOrd,
|
|
|
|
Ord,
|
|
|
|
serde::Deserialize,
|
|
|
|
serde::Serialize,
|
|
|
|
derive_more::Constructor,
|
|
|
|
derive_more::Display,
|
2024-06-19 07:03:08 +01:00
|
|
|
derive_with::With,
|
2024-05-15 07:55:05 +01:00
|
|
|
)]
|
2024-05-12 22:27:20 +01:00
|
|
|
#[display("{}", branches)]
|
2024-05-11 19:46:20 +01:00
|
|
|
pub struct RepoConfig {
|
2024-05-15 07:55:05 +01:00
|
|
|
branches: RepoBranches,
|
|
|
|
source: RepoConfigSource,
|
2024-05-11 19:46:20 +01:00
|
|
|
}
|
|
|
|
impl RepoConfig {
|
2024-06-19 07:02:18 +01:00
|
|
|
pub fn parse(toml: &str) -> Result<Self, toml::de::Error> {
|
2024-05-11 19:46:20 +01:00
|
|
|
toml::from_str(format!("source = \"Repo\"\n{}", toml).as_str())
|
|
|
|
}
|
|
|
|
|
|
|
|
pub const fn branches(&self) -> &RepoBranches {
|
|
|
|
&self.branches
|
|
|
|
}
|
|
|
|
|
|
|
|
pub const fn source(&self) -> RepoConfigSource {
|
|
|
|
self.source
|
|
|
|
}
|
|
|
|
}
|