2024-05-11 19:46:20 +01:00
|
|
|
use crate::RepoBranches;
|
|
|
|
use crate::RepoConfigSource;
|
|
|
|
|
|
|
|
/// 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(
|
|
|
|
Clone, Debug, PartialEq, Eq, serde::Deserialize, derive_more::Constructor, derive_more::Display,
|
|
|
|
)]
|
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 {
|
|
|
|
pub fn load(toml: &str) -> Result<Self, toml::de::Error> {
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|