File tree Expand file tree Collapse file tree 2 files changed +25
-26
lines changed
src/renderer/utils/notifications/handlers Expand file tree Collapse file tree 2 files changed +25
-26
lines changed Original file line number Diff line number Diff line change @@ -63,26 +63,25 @@ export const checkSuiteHandler = new CheckSuiteHandler();
6363export function getCheckSuiteAttributes (
6464 notification : Notification ,
6565) : CheckSuiteAttributes | null {
66- const regexPattern =
66+ const regex =
6767 / ^ (?< workflowName > .* ?) w o r k f l o w r u n ( , A t t e m p t # (?< attemptNumber > \d + ) ) ? (?< statusDisplayName > .* ?) f o r (?< branchName > .* ?) b r a n c h $ / ;
6868
69- const matches = regexPattern . exec ( notification . subject . title ) ;
69+ const match = regex . exec ( notification . subject . title ) ;
7070
71- if ( matches ) {
72- const { groups } = matches ;
73-
74- return {
75- workflowName : groups . workflowName ,
76- attemptNumber : groups . attemptNumber
77- ? Number . parseInt ( groups . attemptNumber )
78- : null ,
79- status : getCheckSuiteStatus ( groups . statusDisplayName ) ,
80- statusDisplayName : groups . statusDisplayName ,
81- branchName : groups . branchName ,
82- } ;
71+ if ( ! match ?. groups ) {
72+ return null ;
8373 }
8474
85- return null ;
75+ const { workflowName, attemptNumber, statusDisplayName, branchName } =
76+ match . groups ;
77+
78+ return {
79+ workflowName,
80+ attemptNumber : attemptNumber ? Number . parseInt ( attemptNumber ) : null ,
81+ status : getCheckSuiteStatus ( statusDisplayName ) ,
82+ statusDisplayName,
83+ branchName,
84+ } ;
8685}
8786
8887function getCheckSuiteStatus ( statusDisplayName : string ) : CheckSuiteStatus {
Original file line number Diff line number Diff line change @@ -46,22 +46,22 @@ export const workflowRunHandler = new WorkflowRunHandler();
4646export function getWorkflowRunAttributes (
4747 notification : Notification ,
4848) : WorkflowRunAttributes | null {
49- const regexPattern =
49+ const regex =
5050 / ^ (?< user > .* ?) r e q u e s t e d y o u r (?< statusDisplayName > .* ?) t o d e p l o y t o a n e n v i r o n m e n t $ / ;
5151
52- const matches = regexPattern . exec ( notification . subject . title ) ;
52+ const match = regex . exec ( notification . subject . title ) ;
5353
54- if ( matches ) {
55- const { groups } = matches ;
56-
57- return {
58- user : groups . user ,
59- status : getWorkflowRunStatus ( groups . statusDisplayName ) ,
60- statusDisplayName : groups . statusDisplayName ,
61- } ;
54+ if ( ! match ?. groups ) {
55+ return null ;
6256 }
6357
64- return null ;
58+ const { user, statusDisplayName } = match . groups ;
59+
60+ return {
61+ user : user ,
62+ status : getWorkflowRunStatus ( statusDisplayName ) ,
63+ statusDisplayName : statusDisplayName ,
64+ } ;
6565}
6666
6767function getWorkflowRunStatus ( statusDisplayName : string ) : CheckSuiteStatus {
You can’t perform that action at this time.
0 commit comments