@@ -42,21 +42,12 @@ public function getStatusChangeFromComment($comment)
42
42
return null ;
43
43
}
44
44
45
- // get what comes *after* status:, with spaces trimmed
46
- // now, the status string "needs review" should be at the 0 character
47
- $ statusString = trim (substr ($ comment , $ statusPosition ));
48
-
49
- $ newStatus = null ;
50
45
foreach (self ::$ triggerWords as $ status => $ triggerWord ) {
51
46
// status should be right at the beginning of the string
52
- if (stripos ($ statusString , $ triggerWord ) === 0 ) {
53
- // don't return immediately - we use the last status
54
- // in the rare case there are multiple
55
- $ newStatus = $ status ;
47
+ if ($ triggerWord === strtolower (substr ($ comment , $ statusPosition , strlen ($ triggerWord )))) {
48
+ return $ status ;
56
49
}
57
50
}
58
-
59
- return $ newStatus ;
60
51
}
61
52
62
53
/**
@@ -99,14 +90,16 @@ public static function getLabelToStatusMap()
99
90
*/
100
91
private function findStatusPosition ($ comment )
101
92
{
102
- $ formats = ['status: ' , '*status*: ' , '**status**: ' ];
93
+ // Match first character after "status:"
94
+ // Case insensitive ("i"), ignores formatting with "*" before or after the ":"
95
+ $ pattern = '~status(\*+:\s*|:[\s\*]*)(\w)~i ' ;
103
96
104
- foreach ($ formats as $ format ) {
105
- $ lastStatusPosition = strripos ($ comment , $ format );
97
+ if (preg_match_all ($ pattern , $ comment , $ matches , PREG_OFFSET_CAPTURE )) {
98
+ // Second subpattern = first status character
99
+ $ lastMatch = end ($ matches [2 ]);
106
100
107
- if ($ lastStatusPosition !== false ) {
108
- return $ lastStatusPosition + strlen ($ format );
109
- }
101
+ // [matched string, offset]
102
+ return $ lastMatch [1 ];
110
103
}
111
104
112
105
return false ;
0 commit comments