@@ -16,20 +16,25 @@ client.once('ready', () => {
16
16
WebhookEvent . on ( 'post' , async ( post : Message ) => {
17
17
console . log ( post ) ;
18
18
19
- const regexInner = `.+(?: \\/ .+)*?(?=]\\(https:\\/\\/gitlab\\.com\\/${ process . env . GITLAB_ORG_NAME . toLowerCase ( ) } \\/[a-z\\-\\/]+\\)` ;
19
+ const regexInner = `.+(?: \\/ .+)*?(?=]\\(https:\\/\\/gitlab\\.com\\/${ process . env . GITLAB_ORG_NAME . toLowerCase ( ) } \\/( [a-z\\-\\/]+) \\)` ;
20
20
const regex = new RegExp ( `(?<=\\[${ process . env . GITLAB_ORG_NAME } / )${ regexInner } )|(?<=\\[)${ regexInner } : Pipeline)` ) ;
21
21
22
22
const matches = post . embeds [ 0 ] . description . match ( regex ) ;
23
23
24
24
if ( ! matches ) return ;
25
25
26
- if ( post . embeds [ 0 ] . description . match ( / P i p e l i n e / ) ) {
26
+ matches [ 0 ] = matches [ 0 ] . replace ( new RegExp ( `${ process . env . GITLAB_ORG_NAME } /(?: .*? \\/)* ` ) , '' ) . replace ( / \/ / g, '–' ) ;
27
+
28
+ const urlify = string => string . toLowerCase ( ) . replace ( / / g, '-' ) . replace ( / - + / g, '-' ) . replace ( / - * – - * / , '/' ) ;
29
+
30
+ const isPipeline = post . embeds [ 0 ] . description . match ( / P i p e l i n e / ) ;
31
+
32
+ if ( isPipeline ) {
27
33
if ( post . embeds [ 0 ] . description . match ( / p a s s e d / ) ) post . embeds [ 0 ] . color = 123456 ;
28
34
else if ( post . embeds [ 0 ] . description . match ( / f a i l e d / ) ) post . embeds [ 0 ] . color = 16711680 ;
35
+ matches [ 0 ] = urlify ( matches [ 2 ] ) ;
29
36
}
30
37
31
- matches [ 0 ] = matches [ 0 ] . replace ( new RegExp ( `${ process . env . GITLAB_ORG_NAME } /(?: .*? \\/)* ` ) , '' ) . replace ( / \/ / g, '–' ) ;
32
-
33
38
const channel = ( await client . channels . fetch (
34
39
process . env . CHANNEL_ID
35
40
) ) as TextChannel ;
@@ -40,7 +45,7 @@ WebhookEvent.on('post', async (post: Message) => {
40
45
( await channel . threads . fetchArchived ( { fetchAll : true } , false ) ) . threads
41
46
) ;
42
47
43
- let thread = allThreads . find ( ( th ) => th . name === matches [ 0 ] ) ;
48
+ let thread = allThreads . find ( ( th ) => ( isPipeline ? urlify ( th . name ) : th . name ) === matches [ 0 ] ) ;
44
49
45
50
thread ??= await channel . threads . create ( {
46
51
name : matches [ 0 ] ,
0 commit comments