From bb9d860ddec4836ebc46d633fd72a1c9ee0318d3 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Fri, 18 Dec 2020 09:22:58 -0800 Subject: [PATCH] Handle gerrit 3.x style internal urls A new style of internal url appears in Gerrit 3.x: /c/PROJECT/+/NUMBER This handles that in internal links and updates the terminal integration docs with the new URL format as well. Change-Id: I30bc6194b1b467b2e6500c5f11e5d06de1aea721 --- README.rst | 2 +- gertty/app.py | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 8717fa1..59ed2fd 100644 --- a/README.rst +++ b/README.rst @@ -203,7 +203,7 @@ in Gertty:: URxvt.keysym.C-Delete: perl:matcher:last URxvt.keysym.M-Delete: perl:matcher:list URxvt.matcher.button: 1 - URxvt.matcher.pattern.1: https:\/\/review.example.org/(\\#\/c\/)?(\\d+)[\w]* + URxvt.matcher.pattern.1: https:\/\/review.example.org/(\\#/c/)?(c/[^\\+]+\\+/)?(\\d+)[\\w]* URxvt.matcher.launcher.1: gertty --open $0 You will want to adjust the pattern to match the review site you are diff --git a/gertty/app.py b/gertty/app.py index e430a81..064812d 100644 --- a/gertty/app.py +++ b/gertty/app.py @@ -637,7 +637,15 @@ class App(object): change = patchset = filename = None path = [x for x in result.path.split('/') if x] if path: - change = path[0] + if path[0] == 'c': + while path: + path.pop(0) + if path[0] == '+': + path.pop(0) + change = path.pop(0) + break + else: + change = path[0] else: path = [x for x in result.fragment.split('/') if x] if path[0] == 'c':