use std::collections::BTreeMap;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default)]
#[serde(default, deny_unknown_fields)]
pub struct GitHubConfig {
pub enabled: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) owner: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) repo: Option<String>,
#[serde(skip_serializing_if = "String::is_empty")]
pub build_command: String,
#[serde(skip_serializing_if = "BTreeMap::is_empty")]
pub artifacts: BTreeMap<String, BTreeMap<String, String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) pull_request_title: Option<String>,
}
impl GitHubConfig {
pub fn enabled_config() -> Self {
Self {
enabled: true,
..Default::default()
}
}
pub fn owner(&self) -> Option<&str> {
self.owner.as_deref()
}
pub fn repo(&self) -> Option<&str> {
self.repo.as_deref()
}
pub fn pull_request_title(&self) -> &str {
self.pull_request_title
.as_deref()
.unwrap_or("Release updates")
}
pub fn with_owner(mut self, owner: String) -> Self {
self.owner = Some(owner);
self
}
pub fn with_repo(mut self, repo: String) -> Self {
self.repo = Some(repo);
self
}
pub fn with_pull_request_title(mut self, title: String) -> Self {
self.pull_request_title = Some(title);
self
}
}