From 0cd55029350d526494747e4a0742a4fabf24815b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konsta=20H=C3=B6ltt=C3=A4?= Date: Wed, 25 Mar 2020 22:04:01 +0200 Subject: [PATCH] scripts: rfr: fix urls with digits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With just (\d+), the very first regex would find a number within a longer string, which for the following example would be wrongly 3, not 2318270. Make it match just a number and nothing else. Interestingly, plain number search would work for most gerrit urls, but let's be specific to avoid accidents. example: https://git-master.nvidia.com/r/c/3rdparty/qnx/src/+/2318270 Also make the list more concise by joining almost identical pairs that differ by just one character: use "?" to make the character optional. Change-Id: Ia1b2ee4270c599ec7bcc2c4375c8a8f498043b27 Signed-off-by: Konsta Hölttä Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2318496 Reviewed-by: automaticguardword Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Thomas Fleury Reviewed-by: Alex Waterman Reviewed-by: mobile promotions Tested-by: mobile promotions GVS: Gerrit_Virtual_Submit --- scripts/rfr | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/scripts/rfr b/scripts/rfr index 3bfd0499d..115bb7420 100755 --- a/scripts/rfr +++ b/scripts/rfr @@ -44,17 +44,12 @@ to_addr = 'sw-mobile-nvgpu-core ' # Gerrit commit URL formats. These are regular expressions to match the # incoming URLs against. -gr_fmts = [ r'(\d+)', - r'http://git-master/r/(\d+)', - r'http://git-master/r/#/c/(\d+)/', - r'http://git-master.nvidia.com/r/(\d+)', - r'http://git-master.nvidia.com/r/#/c/(\d+)/', - r'https://git-master/r/(\d+)', - r'https://git-master/r/#/c/(\d+)/', - r'https://git-master.nvidia.com/r/(\d+)', - r'https://git-master.nvidia.com/r/#/c/(\d+)', - r'https://git-master.nvidia.com/r/#/c/(\d+)/', - r'https://git-master.nvidia.com/r/c/(?:[\w\-_\/]+?)\+/(\d+)' ] +gr_fmts = [ r'^(\d+)$', + r'https?://git-master/r/(\d+)', + r'https?://git-master/r/#/c/(\d+)/', + r'https?://git-master.nvidia.com/r/(\d+)', + r'https?://git-master.nvidia.com/r/#/c/(\d+)/?', + r'https?://git-master.nvidia.com/r/c/(?:[\w\-_\/]+?)\+/(\d+)' ] # The user to use. May be overridden but the default comes from the environment. user = os.environ['USER']