git-next/crates/config/src/webhook/push.rs

40 lines
838 B
Rust
Raw Normal View History

//
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
}
}
#[derive(Debug)]
pub enum Branch {
Main,
Next,
Dev,
}