2024-05-25 11:25:13 +01:00
|
|
|
//
|
|
|
|
use crate as config;
|
|
|
|
|
|
|
|
use derive_more::Constructor;
|
|
|
|
|
|
|
|
#[derive(Debug, Constructor)]
|
|
|
|
pub struct Push {
|
|
|
|
branch: config::BranchName,
|
|
|
|
sha: String,
|
|
|
|
message: String,
|
|
|
|
}
|
|
|
|
impl Push {
|
|
|
|
pub fn branch(&self, repo_branches: &crate::RepoBranches) -> Option<Branch> {
|
|
|
|
if self.branch == repo_branches.main() {
|
|
|
|
return Some(Branch::Main);
|
|
|
|
}
|
|
|
|
if self.branch == repo_branches.next() {
|
|
|
|
return Some(Branch::Next);
|
|
|
|
}
|
|
|
|
if self.branch == repo_branches.dev() {
|
|
|
|
return Some(Branch::Dev);
|
|
|
|
}
|
|
|
|
tracing::warn!(branch = %self.branch, "Unexpected branch");
|
|
|
|
None
|
|
|
|
}
|
|
|
|
pub fn sha(&self) -> &str {
|
|
|
|
&self.sha
|
|
|
|
}
|
|
|
|
pub fn message(&self) -> &str {
|
|
|
|
&self.message
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-01 11:15:04 +01:00
|
|
|
#[derive(Debug, PartialEq, Eq)]
|
2024-05-25 11:25:13 +01:00
|
|
|
pub enum Branch {
|
|
|
|
Main,
|
|
|
|
Next,
|
|
|
|
Dev,
|
|
|
|
}
|