Skip to content

Commit

Permalink
fix: update push event - for create new branch
Browse files Browse the repository at this point in the history
  • Loading branch information
tanhongit committed May 20, 2024
1 parent f1b6096 commit 6a22e26
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 29 deletions.
9 changes: 4 additions & 5 deletions lang/de/events/gitlab/push.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<?php

return [
'default' => [
'title' => '<b>:count</b> new :noun to <b>:repo:<code>:branch</code></b>',
'commit' => '[:commit] :commit_message - by <i>:commit_by</i>',
'pusher' => '👤 Pushed by : <b>:name</b>',
],
'title' => '<b>:count</b> new :noun to <b>:repo:<code>:branch</code></b>',
'commit' => '[:commit] :commit_message - by <i>:commit_by</i>',
'pusher' => 'Pushed by : <b>:name</b>',
'new_branch_title' => '<b>A new branch has been pushed to the project</b> :repo',
];
9 changes: 4 additions & 5 deletions lang/en/events/gitlab/push.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<?php

return [
'default' => [
'title' => '<b>:count</b> new :noun to <b>:repo:<code>:branch</code></b>',
'commit' => '[:commit] :commit_message - by <i>:commit_by</i>',
'pusher' => '👤 Pushed by : <b>:name</b>',
],
'title' => '<b>:count</b> new :noun to <b>:repo:<code>:branch</code></b>',
'commit' => '[:commit] :commit_message - by <i>:commit_by</i>',
'pusher' => 'Pushed by : <b>:name</b>',
'new_branch_title' => '<b>A new branch has been pushed to the project</b> :repo',
];
9 changes: 4 additions & 5 deletions lang/ja/events/gitlab/push.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<?php

return [
'default' => [
'title' => '<b>:count</b> new :noun to <b>:repo:<code>:branch</code></b>',
'commit' => '[:commit] :commit_message - by <i>:commit_by</i>',
'pusher' => '👤 Pushed by : <b>:name</b>',
],
'title' => '<b>:count</b> new :noun to <b>:repo:<code>:branch</code></b>',
'commit' => '[:commit] :commit_message - by <i>:commit_by</i>',
'pusher' => 'Pushed by : <b>:name</b>',
'new_branch_title' => '<b>A new branch has been pushed to the project</b> :repo',
];
8 changes: 4 additions & 4 deletions lang/vi/app.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

return [
'by' => 'by',
'unknown_callback' => 'Unknown Callback. Something went wrong!',
'invalid_request' => 'Invalid Request!',
'branch' => 'Branch',
'by' => 'bởi',
'unknown_callback' => 'Không rõ Callback. Đã xảy ra lỗi!',
'invalid_request' => 'Yêu cầu không hợp lệ!',
'branch' => 'Tên nhánh',
];
9 changes: 4 additions & 5 deletions lang/vi/events/gitlab/push.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<?php

return [
'default' => [
'title' => '<b>:count</b> :noun mới trong <b>:repo:<code>:branch</code></b>',
'commit' => '[:commit] :commit_message - bởi <i>:commit_by</i>',
'pusher' => '👤 Đẩy lên bởi: : <b>:name</b>',
],
'title' => '<b>:count</b> :noun mới trong <b>:repo:<code>:branch</code></b>',
'commit' => '[:commit] :commit_message - bởi <i>:commit_by</i>',
'pusher' => 'Đẩy lên bởi: : <b>:name</b>',
'new_branch_title' => '<b>Một nhánh mới đã được tạo trong dự án</b> :repo',
];
21 changes: 16 additions & 5 deletions resources/views/events/gitlab/push/default.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,35 @@
$ref = explode('/', $payload->ref);
$branch = implode('/', array_slice($ref, 2));
$repo = "🦊<a href='{$payload->project->web_url}'>{$payload->project->path_with_namespace}</a>";
?>

👷⚙️ {!! __('tg-notifier::events/gitlab/push.default.title', [
@if(empty($payload->commits)) {{-- New branch created --}}
🎊 {!! __('tg-notifier::events/gitlab/push.new_branch_title', [
'repo' => $repo,
]) !!}
@else
👷⚙️ {!! __('tg-notifier::events/gitlab/push.title', [
'count' => $count,
'noun' => $noun,
'repo' => "🦑<a href='{$payload->project->web_url}'>{$payload->project->path_with_namespace}</a>",
'repo' => $repo,
'branch' => $branch,
]) !!}

@foreach($payload->commits as $commit)
@php
$commitId = substr($commit->id, -7);
$commit->message = $commit->message ?? '';
$commit->message = explode("\n", $commit->message)[0];
@endphp
{!! __('tg-notifier::events/gitlab/push.default.commit', [
{!! __('tg-notifier::events/gitlab/push.commit', [
'commit' => "<a href='$commit->url'>$commitId</a>",
'commit_message' => $commit->message,
'commit_by' => $commit->author->name,
]) !!}

@endforeach
@endif

{!! __('tg-notifier::events/gitlab/push.default.pusher', ['name' => $payload->user_name]) !!}
🌲 {{ __('tg-notifier::app.branch') }}: <code>{{ $branch }}</code>
👤 {!! __('tg-notifier::events/gitlab/push.pusher', ['name' => $payload->user_name]) !!}

0 comments on commit 6a22e26

Please sign in to comment.