git-next/crates/config/src/repo_config.rs

38 lines
865 B
Rust
Raw Normal View History

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)`
#[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,
)]
#[display("{}", branches)]
pub struct RepoConfig {
branches: RepoBranches,
source: RepoConfigSource,
}
impl RepoConfig {
2024-06-19 07:02:18 +01:00
pub fn parse(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
}
}