Attempt at making hooks less verbose
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
b8987f6eeb
commit
06e5ecf90d
1 changed files with 6 additions and 7 deletions
|
@ -27,7 +27,8 @@ pub fn format_webhook(wh: &WebHook) -> Option<String> {
|
|||
push.commits.len(),
|
||||
push.ref_,
|
||||
);
|
||||
for commit in &push.commits {
|
||||
// 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);
|
||||
|
@ -37,15 +38,13 @@ pub fn format_webhook(wh: &WebHook) -> Option<String> {
|
|||
}
|
||||
text
|
||||
} else {
|
||||
format!(
|
||||
"[{}] {} deleted branch {}",
|
||||
push.project.name, push.user_name, push.ref_,
|
||||
)
|
||||
// Ignore: Branch got deleted
|
||||
return None;
|
||||
}
|
||||
}
|
||||
WebHook::Issue(issue) => {
|
||||
let action = match issue.object_attributes.action {
|
||||
Some(IssueAction::Update) => "updated",
|
||||
Some(IssueAction::Update) => return None,
|
||||
Some(IssueAction::Open) => "opened",
|
||||
Some(IssueAction::Close) => "closed",
|
||||
Some(IssueAction::Reopen) => "reopened",
|
||||
|
@ -68,7 +67,7 @@ pub fn format_webhook(wh: &WebHook) -> Option<String> {
|
|||
}
|
||||
WebHook::MergeRequest(merge_req) => {
|
||||
let action = match merge_req.object_attributes.action {
|
||||
Some(MergeRequestAction::Update) => "updated",
|
||||
Some(MergeRequestAction::Update) => return None,
|
||||
Some(MergeRequestAction::Open) => "opened",
|
||||
Some(MergeRequestAction::Close) => "closed",
|
||||
Some(MergeRequestAction::Reopen) => "reopened",
|
||||
|
|
Loading…
Reference in a new issue