From 3509efc213d785578448c467e81e99d39abb672b Mon Sep 17 00:00:00 2001 From: Mark Jansen Date: Sun, 3 Mar 2019 21:57:42 +0100 Subject: [PATCH] Fix PR command without '#' --- src/pr.php | 2 +- tests/test.php | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pr.php b/src/pr.php index 8a1f573..cbac8a3 100644 --- a/src/pr.php +++ b/src/pr.php @@ -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; diff --git a/tests/test.php b/tests/test.php index 9075672..63e5a04 100644 --- a/tests/test.php +++ b/tests/test.php @@ -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"),