git-next/crates/config/src/repo_config.rs
Paul Campbell ffab1986a7
Some checks failed
ci/woodpecker/cron/cron-docker-builder Pipeline was successful
ci/woodpecker/cron/push-next Pipeline was successful
ci/woodpecker/cron/tag-created Pipeline was successful
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
Rust / build (push) Has been cancelled
ci/woodpecker/push/tag-created Pipeline was successful
refactor: repo-actor: rewrite tests using mockall
2024-06-27 18:58:47 +01:00

38 lines
888 B
Rust

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(
Clone,
Hash,
Debug,
PartialEq,
Eq,
PartialOrd,
Ord,
serde::Deserialize,
serde::Serialize,
derive_more::Constructor,
derive_more::Display,
derive_with::With,
)]
#[display("{}", branches)]
pub struct RepoConfig {
branches: RepoBranches,
source: RepoConfigSource,
}
impl RepoConfig {
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
}
}