Display only pushes to main branch
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
06e5ecf90d
commit
1aee1cd618
1 changed files with 22 additions and 19 deletions
|
@ -19,28 +19,31 @@ use log::debug;
|
||||||
pub fn format_webhook(wh: &WebHook) -> Option<String> {
|
pub fn format_webhook(wh: &WebHook) -> Option<String> {
|
||||||
Some(match wh {
|
Some(match wh {
|
||||||
WebHook::Push(push) => {
|
WebHook::Push(push) => {
|
||||||
if push.commits.len() != 0 {
|
if push.ref_ != "refs/heads/main" {
|
||||||
let mut text = format!(
|
// Ignore: Action not on 'main' branch
|
||||||
"[{}] {} pushed {} commits branch {}",
|
return None;
|
||||||
push.project.name,
|
}
|
||||||
push.user_name,
|
// Unlikely to be reached as 'main' is probably never going to be deleted
|
||||||
push.commits.len(),
|
if push.commits.len() == 0 {
|
||||||
push.ref_,
|
|
||||||
);
|
|
||||||
// Display max 3 commits
|
|
||||||
for commit in push.commits.clone().into_iter().take(3) {
|
|
||||||
match commit.message.lines().nth(0) {
|
|
||||||
Some(subject) => {
|
|
||||||
text = format!("{}\n• {} <{}>", text, subject, commit.url);
|
|
||||||
}
|
|
||||||
None => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
text
|
|
||||||
} else {
|
|
||||||
// Ignore: Branch got deleted
|
// Ignore: Branch got deleted
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
let mut text = format!(
|
||||||
|
"[{}] {} pushed {} commits to main",
|
||||||
|
push.project.name,
|
||||||
|
push.user_name,
|
||||||
|
push.commits.len(),
|
||||||
|
);
|
||||||
|
// Display max 3 commits
|
||||||
|
for commit in push.commits.clone().into_iter().take(3) {
|
||||||
|
match commit.message.lines().nth(0) {
|
||||||
|
Some(subject) => {
|
||||||
|
text = format!("{}\n• {} <{}>", text, subject, commit.url);
|
||||||
|
}
|
||||||
|
None => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
text
|
||||||
}
|
}
|
||||||
WebHook::Issue(issue) => {
|
WebHook::Issue(issue) => {
|
||||||
let action = match issue.object_attributes.action {
|
let action = match issue.object_attributes.action {
|
||||||
|
|
Loading…
Reference in a new issue