Fix PR command without '#'

This commit is contained in:
Mark Jansen 2019-03-03 21:57:42 +01:00
parent 49a2c382b5
commit 3509efc213
No known key found for this signature in database
GPG Key ID: B39240EE84BEAE8B
2 changed files with 6 additions and 1 deletions

View File

@ -37,7 +37,7 @@ class Pr extends Mattermost
return false;
// Do our own validation
if (!preg_match('/^([a-z0-9-_]*)#?([0-9]+)$/i', $this->arg, $matches))
if (!preg_match('/^([a-z0-9-_]*?)#?([0-9]+)$/i', $this->arg, $matches))
{
$this->result['text'] = 'Invalid PR number';
return false;

View File

@ -176,6 +176,11 @@ $tests = array(
'expect' => array('text' => "@ requested `/pr #1`:\n" . $pr_url . "reactos/pull/" . "1"),
'post' => array('token' => $config['pr_token'], 'text' => '#1'),
),
array(
'name' => 'Pr',
'expect' => array('text' => "@ requested `/pr 1234`:\n" . $pr_url . "reactos/pull/" . "1234"),
'post' => array('token' => $config['pr_token'], 'text' => '1234'),
),
array(
'name' => 'Pr',
'expect' => array('text' => "@ requested `/pr rapps-db#333333`:\n" . $pr_url . "rapps-db/pull/" . "333333"),