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.commits.len(),
|
||||||
push.ref_,
|
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) {
|
match commit.message.lines().nth(0) {
|
||||||
Some(subject) => {
|
Some(subject) => {
|
||||||
text = format!("{}\n• {} <{}>", text, subject, commit.url);
|
text = format!("{}\n• {} <{}>", text, subject, commit.url);
|
||||||
|
@ -37,15 +38,13 @@ pub fn format_webhook(wh: &WebHook) -> Option<String> {
|
||||||
}
|
}
|
||||||
text
|
text
|
||||||
} else {
|
} else {
|
||||||
format!(
|
// Ignore: Branch got deleted
|
||||||
"[{}] {} deleted branch {}",
|
return None;
|
||||||
push.project.name, push.user_name, push.ref_,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WebHook::Issue(issue) => {
|
WebHook::Issue(issue) => {
|
||||||
let action = match issue.object_attributes.action {
|
let action = match issue.object_attributes.action {
|
||||||
Some(IssueAction::Update) => "updated",
|
Some(IssueAction::Update) => return None,
|
||||||
Some(IssueAction::Open) => "opened",
|
Some(IssueAction::Open) => "opened",
|
||||||
Some(IssueAction::Close) => "closed",
|
Some(IssueAction::Close) => "closed",
|
||||||
Some(IssueAction::Reopen) => "reopened",
|
Some(IssueAction::Reopen) => "reopened",
|
||||||
|
@ -68,7 +67,7 @@ pub fn format_webhook(wh: &WebHook) -> Option<String> {
|
||||||
}
|
}
|
||||||
WebHook::MergeRequest(merge_req) => {
|
WebHook::MergeRequest(merge_req) => {
|
||||||
let action = match merge_req.object_attributes.action {
|
let action = match merge_req.object_attributes.action {
|
||||||
Some(MergeRequestAction::Update) => "updated",
|
Some(MergeRequestAction::Update) => return None,
|
||||||
Some(MergeRequestAction::Open) => "opened",
|
Some(MergeRequestAction::Open) => "opened",
|
||||||
Some(MergeRequestAction::Close) => "closed",
|
Some(MergeRequestAction::Close) => "closed",
|
||||||
Some(MergeRequestAction::Reopen) => "reopened",
|
Some(MergeRequestAction::Reopen) => "reopened",
|
||||||
|
|
Loading…
Reference in a new issue